fix endpoint of create exam enrollments - fix overwriting exam dates

This commit is contained in:
dominik24c 2022-10-28 00:11:54 +02:00
parent 03c0fb4bb2
commit 03ffd355ed

View File

@ -28,6 +28,15 @@ def create_enrollments(examination_schedule_id: int, data: dict) -> dict:
if start_date.date() != end_date.date():
abort(400, "Invalid dates! Only hours can be different!")
enrollment = Enrollment.query.filter(Enrollment.start_date >= start_date,
Enrollment.start_date < end_date).first()
if enrollment is not None:
abort(400, "You have just created enrollments for this range date!")
enrollment = Enrollment.query.filter(Enrollment.end_date > start_date, Enrollment.end_date <= end_date).first()
if enrollment is not None:
abort(400, "You have just created enrollments for this range date! `1")
delta = end_date - start_date
delta_in_minutes = delta.total_seconds() / 60
if delta_in_minutes % prt != 0: