diff --git a/backend/app/students/routes/enrollments.py b/backend/app/students/routes/enrollments.py index a46e26b..196376f 100644 --- a/backend/app/students/routes/enrollments.py +++ b/backend/app/students/routes/enrollments.py @@ -1,6 +1,7 @@ from apiflask import APIBlueprint from flask import abort +from ...base.mode import EnrollmentsMode from ...base.schemas import MessageSchema from ...dependencies import db from ...examination_schedule.models import ExaminationSchedule @@ -38,14 +39,17 @@ def assign_your_group_to_term_of_defence( if term_of_defence is None or (ex := term_of_defence.examination_schedule) is None: abort(400, "Term of defence not found!") - g = ( + if ex.open_enrollments != EnrollmentsMode.OPEN.value: + abort(400, "Enrollments is closed! You have been delayed!") + + group = ( Group.query.join(ProjectSupervisor) .filter(Group.year_group_id == ex.year_group_id) .join(Group.students) .filter_by(index=student.index) .first() ) - if g is None or g.project_supervisor is None: + if group is None or group.project_supervisor is None: abort( 400, "You don't have a group or your group doesn't" @@ -53,7 +57,7 @@ def assign_your_group_to_term_of_defence( ) defence = TermOfDefence.query.filter( - TermOfDefence.group_id == g.id, + TermOfDefence.group_id == group.id, TermOfDefence.examination_schedule_id == examination_schedule_id, ).first() if defence is not None: @@ -61,14 +65,14 @@ def assign_your_group_to_term_of_defence( td = ( TermOfDefence.query.join(TermOfDefence.members_of_committee) - .filter_by(id=g.project_supervisor_id) + .filter_by(id=group.project_supervisor_id) .first() ) if td is None: abort(400, "Your project supervisor is not in committee!") - term_of_defence.group_id = g.id + term_of_defence.group_id = group.id db.session.add(term_of_defence) db.session.commit() return {"message": "You have just assigned the group for this exam date!"} diff --git a/backend/tests/functional_tests/coordinator/test_enrollments.py b/backend/tests/functional_tests/coordinator/test_enrollments.py new file mode 100644 index 0000000..e69de29 diff --git a/backend/tests/functional_tests/project_supervisors/test_project_grade_sheet.py b/backend/tests/functional_tests/project_supervisors/test_project_grade_sheet.py new file mode 100644 index 0000000..e69de29 diff --git a/backend/tests/functional_tests/students/test_project_grade_sheet.py b/backend/tests/functional_tests/students/test_project_grade_sheet.py new file mode 100644 index 0000000..e69de29