From 3e25ff148f2d94a267c081389e40d7fc99c3717b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Palma?= Date: Sun, 9 Feb 2025 14:20:33 +0000 Subject: [PATCH] fix: faulty validation direct exchange logic --- .../controllers/ExchangeValidationController.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/django/university/controllers/ExchangeValidationController.py b/django/university/controllers/ExchangeValidationController.py index 748b1c2..4c5fe36 100644 --- a/django/university/controllers/ExchangeValidationController.py +++ b/django/university/controllers/ExchangeValidationController.py @@ -76,10 +76,9 @@ def validate_direct_exchange(self, exchange_id: int) -> ExchangeValidationRespon schedule = {} for participant in exchange_participants: if participant.participant_nmec not in schedule.keys(): - schedule[participant.participant_nmec] = build_student_schedule_dict(SigarraController().get_student_schedule(int(participant.participant_nmec)).data) - - # Get new schedule from accepted changes - ExchangeController.update_schedule_accepted_exchanges(participant.participant_nmec, list(schedule[participant.participant_nmec].values())) + new_schedule = SigarraController().get_student_schedule(int(participant.participant_nmec)).data + ExchangeController.update_schedule_accepted_exchanges(participant.participant_nmec, new_schedule) + schedule[participant.participant_nmec] = build_student_schedule_dict(new_schedule) # 2. Check if users are inside classes they will exchange from with for username in schedule.keys(): @@ -87,6 +86,7 @@ def validate_direct_exchange(self, exchange_id: int) -> ExchangeValidationRespon for entry in participant_entries: if (entry.class_participant_goes_from, int(entry.course_unit_id)) not in list(schedule[username].keys()): + return ExchangeValidationResponse(False, ExchangeStatus.STUDENTS_NOT_ENROLLED) # 3. Alter the schedule of the users according to the exchange metadata