Skip to content

Commit

Permalink
Merge pull request #197 from NIAEFEUP/fix/faulty-validation-direct-ex…
Browse files Browse the repository at this point in the history
…change-logic

fix: faulty validation direct exchange logic
  • Loading branch information
tomaspalma authored Feb 9, 2025
2 parents f406e48 + 3e25ff1 commit b0d870f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions django/university/controllers/ExchangeValidationController.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,17 @@ 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():
participant_entries = list(exchange_participants.filter(participant_nmec=username))

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
Expand Down

0 comments on commit b0d870f

Please sign in to comment.