Skip to content

Commit

Permalink
fix: no submissions before start
Browse files Browse the repository at this point in the history
  • Loading branch information
Topvennie committed May 20, 2024
1 parent 82cf92f commit 9bf111c
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 40 deletions.
44 changes: 24 additions & 20 deletions backend/api/locale/en/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-05-15 19:49+0200\n"
"POT-Creation-Date: 2024-05-20 12:24+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down Expand Up @@ -180,39 +180,43 @@ msgstr "The student is already in the group."
msgid "group.errors.not_present"
msgstr "The student is currently not in the group."

#: serializers/project_serializer.py:22
#: serializers/project_serializer.py:23
msgid "project.errors.invalid_instance"
msgstr "Error while parsing the provided zip."

#: serializers/project_serializer.py:81
#: serializers/project_serializer.py:122
msgid "project.errors.context"
msgstr "The project is not supplied in the context."

#: serializers/project_serializer.py:86
#: serializers/project_serializer.py:127
msgid "project.errors.start_date_in_past"
msgstr "The start date of the project lies in the past."

#: serializers/project_serializer.py:100
#: serializers/project_serializer.py:141
msgid "project.errors.deadline_before_start_date"
msgstr "The deadline of the project lies before the start date of the project."

#: serializers/project_serializer.py:142
#: serializers/project_serializer.py:183
msgid "project.errors.zip_structure"
msgstr "Error while parsing the provided zip."

#: serializers/submission_serializer.py:96 tests/test_submission.py:275
#: serializers/submission_serializer.py:98
msgid "project.error.submissions.project_not_started"
msgstr "The project hasn't started yet."

#: serializers/submission_serializer.py:102 tests/test_submission.py:275
msgid "project.error.submissions.past_project"
msgstr "The deadline of the project has already passed."

#: serializers/submission_serializer.py:99 tests/test_submission.py:346
#: serializers/submission_serializer.py:105 tests/test_submission.py:346
msgid "project.error.submissions.non_visible_project"
msgstr "The project is currently in a non-visible state."

#: serializers/submission_serializer.py:102 tests/test_submission.py:376
#: serializers/submission_serializer.py:108 tests/test_submission.py:376
msgid "project.error.submissions.archived_project"
msgstr "The project is archived."

#: serializers/submission_serializer.py:105
#: serializers/submission_serializer.py:111
msgid "project.error.submissions.no_files"
msgstr "The submission is empty."

Expand All @@ -228,39 +232,39 @@ msgstr "The teacher was successfully added."
msgid "teachers.success.destroy"
msgstr "The teacher was successfully destroyed."

#: views/course_view.py:137
#: views/course_view.py:136
msgid "courses.success.assistants.add"
msgstr "The assistant was successfully added to the course."

#: views/course_view.py:164
#: views/course_view.py:163
msgid "courses.success.assistants.remove"
msgstr "The assistant was successfully removed from the course."

#: views/course_view.py:226
#: views/course_view.py:225
msgid "courses.success.students.add"
msgstr "The student was successfully added to the course."

#: views/course_view.py:247
#: views/course_view.py:246
msgid "courses.success.students.remove"
msgstr "The student was successfully removed from the course."

#: views/course_view.py:292
#: views/course_view.py:291
msgid "courses.success.teachers.add"
msgstr "The teacher was successfully added to the course."

#: views/course_view.py:316
#: views/course_view.py:315
msgid "courses.success.teachers.remove"
msgstr "The teacher was successfully removed from the course."

#: views/group_view.py:74
#: views/group_view.py:73
msgid "group.success.students.add"
msgstr "The student was successfully added to the group."

#: views/group_view.py:94
#: views/group_view.py:93
msgid "group.success.students.remove"
msgstr "The student was successfully removed from the group."

#: views/group_view.py:113
#: views/group_view.py:112
msgid "group.success.submissions.add"
msgstr "The submission was successfully added to the group."

Expand Down Expand Up @@ -288,6 +292,6 @@ msgstr "No zip file available."
msgid "extra_check_result.download.log"
msgstr "No log file available."

#: views/submission_view.py:60
#: views/submission_view.py:59
msgid "extra_check_result.download.artifact"
msgstr "No artifact available."
44 changes: 24 additions & 20 deletions backend/api/locale/nl/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-05-15 19:49+0200\n"
"POT-Creation-Date: 2024-05-20 12:24+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down Expand Up @@ -181,39 +181,43 @@ msgstr "De student bevindt zich al in de groep."
msgid "group.errors.not_present"
msgstr "De student bevindt zich niet in de groep."

#: serializers/project_serializer.py:22
#: serializers/project_serializer.py:23
msgid "project.errors.invalid_instance"
msgstr "Error tijdens de zip te overlopen."

#: serializers/project_serializer.py:81
#: serializers/project_serializer.py:122
msgid "project.errors.context"
msgstr "Het project is niet meegegeven als context waar dat nodig is."

#: serializers/project_serializer.py:86
#: serializers/project_serializer.py:127
msgid "project.errors.start_date_in_past"
msgstr "De startdatum van het project ligt in het verleden."

#: serializers/project_serializer.py:100
#: serializers/project_serializer.py:141
msgid "project.errors.deadline_before_start_date"
msgstr "De uiterste inleverdatum voor het project ligt voor de startdatum."

#: serializers/project_serializer.py:142
#: serializers/project_serializer.py:183
msgid "project.errors.zip_structure"
msgstr "Error tijdens de zip te overlopen."

#: serializers/submission_serializer.py:96 tests/test_submission.py:275
#: serializers/submission_serializer.py:98
msgid "project.error.submissions.project_not_started"
msgstr "Het project is nog niet begonnen."

#: serializers/submission_serializer.py:102 tests/test_submission.py:275
msgid "project.error.submissions.past_project"
msgstr "De uiterste inleverdatum voor het project is gepasseerd."

#: serializers/submission_serializer.py:99 tests/test_submission.py:346
#: serializers/submission_serializer.py:105 tests/test_submission.py:346
msgid "project.error.submissions.non_visible_project"
msgstr "Het project is niet zichtbaar."

#: serializers/submission_serializer.py:102 tests/test_submission.py:376
#: serializers/submission_serializer.py:108 tests/test_submission.py:376
msgid "project.error.submissions.archived_project"
msgstr "Het project is gearchiveerd."

#: serializers/submission_serializer.py:105
#: serializers/submission_serializer.py:111
msgid "project.error.submissions.no_files"
msgstr "De indiening is leeg"

Expand All @@ -229,39 +233,39 @@ msgstr "De lesgever is successvol toegevoegd."
msgid "teachers.success.destroy"
msgstr "De lesgever is succesvol verwijderd."

#: views/course_view.py:137
#: views/course_view.py:136
msgid "courses.success.assistants.add"
msgstr "De assistent is succesvol toegevoegd aan de opleiding."

#: views/course_view.py:164
#: views/course_view.py:163
msgid "courses.success.assistants.remove"
msgstr "De assistent is succesvol verwijderd uit de opleiding."

#: views/course_view.py:226
#: views/course_view.py:225
msgid "courses.success.students.add"
msgstr "De student is succesvol toegevoegd aan de opleiding."

#: views/course_view.py:247
#: views/course_view.py:246
msgid "courses.success.students.remove"
msgstr "De student is succesvol verwijderd uit de opleiding."

#: views/course_view.py:292
#: views/course_view.py:291
msgid "courses.success.teachers.add"
msgstr "De lesgever is succesvol toegevoegd aan de opleiding."

#: views/course_view.py:316
#: views/course_view.py:315
msgid "courses.success.teachers.remove"
msgstr "De lesgever is succesvol verwijderd uit de opleiding."

#: views/group_view.py:74
#: views/group_view.py:73
msgid "group.success.students.add"
msgstr "De student is succesvol toegevoegd aan de groep."

#: views/group_view.py:94
#: views/group_view.py:93
msgid "group.success.students.remove"
msgstr "De student is succesvol verwijderd uit de groep."

#: views/group_view.py:113
#: views/group_view.py:112
msgid "group.success.submissions.add"
msgstr "De indiening is succesvol toegevoegd aan de groep."

Expand Down Expand Up @@ -289,7 +293,7 @@ msgstr "Geen zip bestand beschikbaar."
msgid "extra_check_result.download.log"
msgstr "Geen log bestand beschikbaar."

#: views/submission_view.py:60
#: views/submission_view.py:59
#, fuzzy
#| msgid "extra_check_result.download.log"
msgid "extra_check_result.download.artifact"
Expand Down
5 changes: 5 additions & 0 deletions backend/api/models/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ def deadline_passed(self):
now = timezone.now()
return now > self.deadline

def has_started(self):
"""Returns True if the project has started."""
now = timezone.now()
return now >= self.start_date

def is_archived(self):
"""Returns True if a project is archived."""
return self.archived
Expand Down
3 changes: 3 additions & 0 deletions backend/api/serializers/submission_serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ def validate(self, attrs):
group: Group = self.context["group"]
project: Project = group.project

if not project.has_started():
raise ValidationError(_("project.error.submissions.project_not_started"))

# Check if the project's deadline is not passed.
if project.deadline_passed():
raise ValidationError(_("project.error.submissions.past_project"))
Expand Down

0 comments on commit 9bf111c

Please sign in to comment.