2022-10-27 15:59:02 +02:00
|
|
|
import datetime
|
|
|
|
|
|
|
|
from flask import abort
|
|
|
|
|
|
|
|
from ..dependencies import db
|
2022-11-12 16:18:07 +01:00
|
|
|
from ..examination_schedule.models import ExaminationSchedule
|
2022-10-27 15:59:02 +02:00
|
|
|
|
|
|
|
|
|
|
|
def get_enrollment_by_enrollment_and_examination_schedule_ids(examination_schedule_id: int,
|
2022-11-12 16:18:07 +01:00
|
|
|
enrollment_id: int) -> None:
|
2022-10-27 15:59:02 +02:00
|
|
|
enrollment = db.session.query(Enrollment). \
|
|
|
|
join(ExaminationSchedule, isouter=True).join(Committee, isouter=True). \
|
|
|
|
filter(ExaminationSchedule.id == examination_schedule_id). \
|
|
|
|
filter(Enrollment.id == enrollment_id). \
|
|
|
|
first()
|
|
|
|
|
|
|
|
if enrollment is None:
|
|
|
|
abort(404, "Examination schedule doesn't exist!")
|
|
|
|
|
|
|
|
return enrollment
|
|
|
|
|
|
|
|
|
|
|
|
def check_the_enrollments_has_just_started(start_date: datetime.datetime, action: str) -> None:
|
|
|
|
now = datetime.datetime.utcnow()
|
|
|
|
|
|
|
|
if start_date is not None and start_date.timestamp() < now.timestamp():
|
|
|
|
abort(403, f"Forbidden! Enrollment has just started! You cannot {action} from the exam committees!")
|