fix endpoint of create exam enrollments - fix overwriting exam dates
This commit is contained in:
parent
03c0fb4bb2
commit
03ffd355ed
@ -28,6 +28,15 @@ def create_enrollments(examination_schedule_id: int, data: dict) -> dict:
|
|||||||
if start_date.date() != end_date.date():
|
if start_date.date() != end_date.date():
|
||||||
abort(400, "Invalid dates! Only hours can be different!")
|
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 = end_date - start_date
|
||||||
delta_in_minutes = delta.total_seconds() / 60
|
delta_in_minutes = delta.total_seconds() / 60
|
||||||
if delta_in_minutes % prt != 0:
|
if delta_in_minutes % prt != 0:
|
||||||
|
Loading…
Reference in New Issue
Block a user