From ac9743a4a278ab377fac7799e9126befe3345027 Mon Sep 17 00:00:00 2001 From: Topvennie Date: Mon, 20 May 2024 12:30:27 +0200 Subject: [PATCH] fix: no leaving single groups --- backend/api/locale/en/LC_MESSAGES/django.po | 58 +++++++++++---------- backend/api/locale/nl/LC_MESSAGES/django.po | 58 +++++++++++---------- backend/api/serializers/group_serializer.py | 9 +++- 3 files changed, 69 insertions(+), 56 deletions(-) diff --git a/backend/api/locale/en/LC_MESSAGES/django.po b/backend/api/locale/en/LC_MESSAGES/django.po index dbf3b355..51b4c470 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:28+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -152,67 +152,71 @@ msgstr "User is not allowed to assign othher owners than himself to the image." msgid "docker.errors.custom" msgstr "User is not allowed to create public images" -#: serializers/group_serializer.py:56 +#: serializers/group_serializer.py:57 msgid "group.errors.score_exceeds_max" msgstr "The score exceeds the group's max score." -#: serializers/group_serializer.py:66 serializers/group_serializer.py:96 +#: serializers/group_serializer.py:67 serializers/group_serializer.py:97 msgid "group.error.context" msgstr "The group is not supplied in the context." -#: serializers/group_serializer.py:74 serializers/group_serializer.py:108 +#: serializers/group_serializer.py:75 serializers/group_serializer.py:113 msgid "group.errors.locked" msgstr "The group is currently locked." -#: serializers/group_serializer.py:78 +#: serializers/group_serializer.py:79 msgid "group.errors.full" msgstr "The group is already full." -#: serializers/group_serializer.py:82 +#: serializers/group_serializer.py:83 msgid "group.errors.not_in_course" msgstr "The student is not present in the related course." -#: serializers/group_serializer.py:86 +#: serializers/group_serializer.py:87 msgid "group.errors.already_in_group" msgstr "The student is already in the group." -#: serializers/group_serializer.py:104 +#: serializers/group_serializer.py:105 +msgid "group.errors.size_one" +msgstr "Unable to leave a group with size 1." + +#: serializers/group_serializer.py:109 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:99 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:102 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:105 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:108 msgid "project.error.submissions.no_files" msgstr "The submission is empty." @@ -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." @@ -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." diff --git a/backend/api/locale/nl/LC_MESSAGES/django.po b/backend/api/locale/nl/LC_MESSAGES/django.po index 7acb1b3d..4e39a9b6 100755 --- a/backend/api/locale/nl/LC_MESSAGES/django.po +++ b/backend/api/locale/nl/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:28+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -152,68 +152,72 @@ msgstr "Gebruiker is alleen toegelaten om zichzelf als eigenaar op te geven" msgid "docker.errors.custom" msgstr "Gebruiker is niet toegelaten om publieke afbeeldingen te maken" -#: serializers/group_serializer.py:56 +#: serializers/group_serializer.py:57 msgid "group.errors.score_exceeds_max" msgstr "De score van de groep is groter dan de maximum score." -#: serializers/group_serializer.py:66 serializers/group_serializer.py:96 +#: serializers/group_serializer.py:67 serializers/group_serializer.py:97 msgid "group.error.context" msgstr "De groep is niet meegegeven als context waar dat nodig is." -#: serializers/group_serializer.py:74 serializers/group_serializer.py:108 +#: serializers/group_serializer.py:75 serializers/group_serializer.py:113 msgid "group.errors.locked" msgstr "De groep is momenteel vergrendeld." -#: serializers/group_serializer.py:78 +#: serializers/group_serializer.py:79 msgid "group.errors.full" msgstr "De groep is al vol." -#: serializers/group_serializer.py:82 +#: serializers/group_serializer.py:83 msgid "group.errors.not_in_course" msgstr "" "De student bevindt zich niet in de opleiding waartoe het project hoort." -#: serializers/group_serializer.py:86 +#: serializers/group_serializer.py:87 msgid "group.errors.already_in_group" msgstr "De student bevindt zich al in de groep." -#: serializers/group_serializer.py:104 +#: serializers/group_serializer.py:105 +msgid "group.errors.size_one" +msgstr "Het is niet mogelijk om een group met grootte 1 te verlaten." + +#: serializers/group_serializer.py:109 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:99 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:102 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:105 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:108 msgid "project.error.submissions.no_files" msgstr "De indiening is leeg" @@ -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." @@ -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" diff --git a/backend/api/serializers/group_serializer.py b/backend/api/serializers/group_serializer.py index 3865f7a2..e929b1cc 100644 --- a/backend/api/serializers/group_serializer.py +++ b/backend/api/serializers/group_serializer.py @@ -1,8 +1,9 @@ +from api.models.assistant import Assistant from api.models.group import Group from api.models.student import Student -from api.models.assistant import Assistant from api.models.teacher import Teacher -from api.permissions.role_permissions import is_student, is_assistant, is_teacher +from api.permissions.role_permissions import (is_assistant, is_student, + is_teacher) from api.serializers.project_serializer import ProjectSerializer from api.serializers.student_serializer import StudentIDSerializer from django.utils.translation import gettext @@ -99,6 +100,10 @@ def validate(self, attrs): group: Group = self.context["group"] student: Student = attrs["student"] + # Make sure the group size is not 1 + if group.project.group_size == 1: + raise ValidationError(gettext("group.errors.size_one")) + # Make sure the student was in the group if not group.students.filter(id=student.id).exists(): raise ValidationError(gettext("group.errors.not_present"))