system-pri/backend/app/examination_schedule/routes/examination_schedule.py

33 lines
1.1 KiB
Python

import datetime
from apiflask import APIBlueprint
from flask import abort
from ...dependencies import db
from ..models import ExaminationSchedule
from ..schemas import ExaminationScheduleListSchema
bp = APIBlueprint("list_of_examination_schedule", __name__, url_prefix="/")
@bp.get('/project-supervisor-view/')
@bp.output(ExaminationScheduleListSchema)
def list_examination_schedule_for_project_supervisors() -> dict:
now = datetime.datetime.utcnow()
examination_schedules = db.session.query(ExaminationSchedule). \
filter(ExaminationSchedule.start_date > now). \
all()
return {'examination_schedules': examination_schedules}
@bp.get('/students-view/')
@bp.output(ExaminationScheduleListSchema)
def list_examination_schedule_for_students() -> dict:
# in the future filter after the mode of examination schedule if we will have authorization module
now = datetime.datetime.utcnow()
examination_schedules = db.session.query(ExaminationSchedule).\
filter(ExaminationSchedule.start_date < now).\
filter(ExaminationSchedule.end_date > now).\
all()
return {'examination_schedules': examination_schedules}