From 6b1377f6653c6cdcc5cbc87b5baca48284141b5c Mon Sep 17 00:00:00 2001 From: Topvennie Date: Mon, 20 May 2024 12:25:31 +0200 Subject: [PATCH 1/6] fix: no submissions before start --- backend/api/locale/en/LC_MESSAGES/django.po | 44 ++++++++++--------- backend/api/locale/nl/LC_MESSAGES/django.po | 20 +++++++++ backend/api/models/project.py | 5 +++ .../api/serializers/submission_serializer.py | 3 ++ 4 files changed, 52 insertions(+), 20 deletions(-) diff --git a/backend/api/locale/en/LC_MESSAGES/django.po b/backend/api/locale/en/LC_MESSAGES/django.po index 9015d015..c481af8c 100755 --- a/backend/api/locale/en/LC_MESSAGES/django.po +++ b/backend/api/locale/en/LC_MESSAGES/django.po @@ -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 \n" "Language-Team: LANGUAGE \n" @@ -188,39 +188,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." @@ -236,39 +240,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." @@ -296,6 +300,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." diff --git a/backend/api/locale/nl/LC_MESSAGES/django.po b/backend/api/locale/nl/LC_MESSAGES/django.po index 4e39a9b6..721fb214 100755 --- a/backend/api/locale/nl/LC_MESSAGES/django.po +++ b/backend/api/locale/nl/LC_MESSAGES/django.po @@ -205,6 +205,7 @@ msgstr "De uiterste inleverdatum voor het project ligt voor de startdatum." msgid "project.errors.zip_structure" msgstr "Error tijdens de zip te overlopen." +<<<<<<< HEAD #: serializers/submission_serializer.py:99 tests/test_submission.py:275 msgid "project.error.submissions.past_project" msgstr "De uiterste inleverdatum voor het project is gepasseerd." @@ -218,6 +219,25 @@ msgid "project.error.submissions.archived_project" msgstr "Het project is gearchiveerd." #: serializers/submission_serializer.py:108 +======= +#: 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:105 tests/test_submission.py:346 +msgid "project.error.submissions.non_visible_project" +msgstr "Het project is niet zichtbaar." + +#: 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:111 +>>>>>>> 9bf111cb (fix: no submissions before start) msgid "project.error.submissions.no_files" msgstr "De indiening is leeg" diff --git a/backend/api/models/project.py b/backend/api/models/project.py index ceb786c1..d1d250c6 100644 --- a/backend/api/models/project.py +++ b/backend/api/models/project.py @@ -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 diff --git a/backend/api/serializers/submission_serializer.py b/backend/api/serializers/submission_serializer.py index adf5f42e..9683ac24 100644 --- a/backend/api/serializers/submission_serializer.py +++ b/backend/api/serializers/submission_serializer.py @@ -98,6 +98,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")) From c0d6a4e8523fba5211c43ce9bea17abc44ccaabf Mon Sep 17 00:00:00 2001 From: Topvennie Date: Thu, 23 May 2024 15:57:49 +0200 Subject: [PATCH 2/6] chore: move project startdate --- backend/api/fixtures/realistic/realistic.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/api/fixtures/realistic/realistic.yaml b/backend/api/fixtures/realistic/realistic.yaml index 5c3fcaf3..1ecd87b4 100644 --- a/backend/api/fixtures/realistic/realistic.yaml +++ b/backend/api/fixtures/realistic/realistic.yaml @@ -33,7 +33,7 @@ visible: true archived: false locked_groups: false - start_date: 2024-12-12T00:00:00Z + start_date: 2023-12-12T00:00:00Z deadline: 2025-01-01T00:00:00Z max_score: 100 score_visible: false From 4194bcc829ec9dae429e0043f03bfb755773e38b Mon Sep 17 00:00:00 2001 From: Topvennie Date: Thu, 23 May 2024 16:02:10 +0200 Subject: [PATCH 3/6] chore: demo --- backend/api/fixtures/realistic/realistic.yaml | 4 +++- .../realistic/projects/0/0/checks/generate_gibberish.sh | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/backend/api/fixtures/realistic/realistic.yaml b/backend/api/fixtures/realistic/realistic.yaml index 1ecd87b4..e03972f9 100644 --- a/backend/api/fixtures/realistic/realistic.yaml +++ b/backend/api/fixtures/realistic/realistic.yaml @@ -134,7 +134,9 @@ project: 0 obligated_extensions: - 0 - blocked_extensions: [] + - 3 + blocked_extensions: + - 1 - model: api.structurecheck pk: 1 fields: diff --git a/backend/data/fixtures/realistic/projects/0/0/checks/generate_gibberish.sh b/backend/data/fixtures/realistic/projects/0/0/checks/generate_gibberish.sh index 9690ec1e..2deb94d8 100755 --- a/backend/data/fixtures/realistic/projects/0/0/checks/generate_gibberish.sh +++ b/backend/data/fixtures/realistic/projects/0/0/checks/generate_gibberish.sh @@ -19,4 +19,4 @@ done # Generate an artifact -wget https://golang.org/doc/gopher/modelsheet.jpg -P artifacts +wget https://upload.wikimedia.org/wikipedia/commons/5/5e/Logo_UGent_NL_RGB_2400_kleur-op-wit.png -P artifacts From 70694c613d17398bbd61b071ecdee8093e52bbf9 Mon Sep 17 00:00:00 2001 From: Topvennie Date: Thu, 23 May 2024 16:05:50 +0200 Subject: [PATCH 4/6] chore: demo --- backend/api/fixtures/realistic/realistic.yaml | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/backend/api/fixtures/realistic/realistic.yaml b/backend/api/fixtures/realistic/realistic.yaml index e03972f9..f7664d29 100644 --- a/backend/api/fixtures/realistic/realistic.yaml +++ b/backend/api/fixtures/realistic/realistic.yaml @@ -134,11 +134,18 @@ project: 0 obligated_extensions: - 0 - - 3 blocked_extensions: - 1 - model: api.structurecheck pk: 1 + fields: + path: "verslag/" + project: 0 + obligated_extensions: + - 3 + blocked_extensions: [] +- model: api.structurecheck + pk: 2 fields: path: src/ project: 1 @@ -147,7 +154,7 @@ blocked_extensions: - 2 - model: api.structurecheck - pk: 2 + pk: 3 fields: path: verslag/ project: 1 @@ -155,7 +162,7 @@ - 3 blocked_extensions: [] - model: api.structurecheck - pk: 3 + pk: 4 fields: path: "" project: 3 From 2b89a87e5bc08db6759a2e764500fa90e145a089 Mon Sep 17 00:00:00 2001 From: Topvennie Date: Thu, 23 May 2024 16:28:27 +0200 Subject: [PATCH 5/6] chore: allow joining group after start --- backend/api/serializers/group_serializer.py | 4 ---- development.sh | 1 - 2 files changed, 5 deletions(-) diff --git a/backend/api/serializers/group_serializer.py b/backend/api/serializers/group_serializer.py index b62102c7..726a0a80 100644 --- a/backend/api/serializers/group_serializer.py +++ b/backend/api/serializers/group_serializer.py @@ -81,10 +81,6 @@ def validate(self, attrs): group: Group = self.context["group"] student: Student = attrs["student"] - # Make sure a student can't join if groups are locked - if group.project.is_groups_locked(): - raise ValidationError(gettext("group.errors.locked")) - # Make sure the group is not already full if group.is_full(): raise ValidationError(gettext("group.errors.full")) diff --git a/development.sh b/development.sh index 5a83cf9d..df298669 100755 --- a/development.sh +++ b/development.sh @@ -134,7 +134,6 @@ if [ "$data" != "" ]; then docker-compose -f development.yml up -d backend redis celery echo "Clearing, Migrating & Populating the database" - # We have nog fixtures for notification yet. docker-compose -f development.yml run backend sh -c "python manage.py flush --no-input; python manage.py migrate; python manage.py loaddata notifications/fixtures/$data/*; python manage.py loaddata authentication/fixtures/$data/*; python manage.py loaddata api/fixtures/$data/*;" echo "Stopping the services" From 93ecef323d201f40fedd06356368c7483193178a Mon Sep 17 00:00:00 2001 From: Topvennie Date: Thu, 23 May 2024 16:31:42 +0200 Subject: [PATCH 6/6] chore: git merge --- backend/api/locale/nl/LC_MESSAGES/django.po | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/backend/api/locale/nl/LC_MESSAGES/django.po b/backend/api/locale/nl/LC_MESSAGES/django.po index 721fb214..4e39a9b6 100755 --- a/backend/api/locale/nl/LC_MESSAGES/django.po +++ b/backend/api/locale/nl/LC_MESSAGES/django.po @@ -205,7 +205,6 @@ msgstr "De uiterste inleverdatum voor het project ligt voor de startdatum." msgid "project.errors.zip_structure" msgstr "Error tijdens de zip te overlopen." -<<<<<<< HEAD #: serializers/submission_serializer.py:99 tests/test_submission.py:275 msgid "project.error.submissions.past_project" msgstr "De uiterste inleverdatum voor het project is gepasseerd." @@ -219,25 +218,6 @@ msgid "project.error.submissions.archived_project" msgstr "Het project is gearchiveerd." #: serializers/submission_serializer.py:108 -======= -#: 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:105 tests/test_submission.py:346 -msgid "project.error.submissions.non_visible_project" -msgstr "Het project is niet zichtbaar." - -#: 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:111 ->>>>>>> 9bf111cb (fix: no submissions before start) msgid "project.error.submissions.no_files" msgstr "De indiening is leeg"