28 lines
1014 B
Python
28 lines
1014 B
Python
import datetime
|
|
|
|
from flask import abort
|
|
|
|
from ..dependencies import db
|
|
from ..examination_schedule.models import ExaminationSchedule
|
|
|
|
|
|
def get_enrollment_by_enrollment_and_examination_schedule_ids(examination_schedule_id: int,
|
|
enrollment_id: int) -> None:
|
|
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!")
|