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

69 lines
2.3 KiB
Python
Raw Normal View History

from ..base.mode import EnrollmentsMode
from ..base.models import Base
from ..dependencies import db
class ExaminationSchedule(Base):
__tablename__ = "examination_schedules"
title = db.Column(db.String(100), unique=True, nullable=False)
duration_time = db.Column(db.Integer, nullable=False) # in minutes
open_enrollments = db.Column(
db.String(1), default=EnrollmentsMode.INIT.value, nullable=False
)
start_date = db.Column(db.DateTime, nullable=False)
end_date = db.Column(db.DateTime, nullable=False)
year_group_id = db.Column(
db.Integer, db.ForeignKey("year_groups.id"), nullable=False
)
year_group = db.relationship("YearGroup", backref="examination_schedules")
committee = db.Table(
"committees",
db.Column("term_of_defence_id", db.ForeignKey("term_of_defences.id")),
db.Column("project_supervisor_id", db.ForeignKey("project_supervisors.id")),
)
class TermOfDefence(Base):
__tablename__ = "term_of_defences"
start_date = db.Column(db.DateTime, nullable=False)
end_date = db.Column(db.DateTime, nullable=False)
examination_schedule_id = db.Column(
db.Integer, db.ForeignKey("examination_schedules.id")
)
examination_schedule = db.relationship(
"ExaminationSchedule", backref="term_of_defences"
)
group_id = db.Column(db.Integer, db.ForeignKey("groups.id"))
group = db.relationship(
"Group", uselist=False, backref="term_of_defence", lazy="joined"
)
members_of_committee = db.relationship(
"ProjectSupervisor", secondary=committee, lazy="joined"
)
chairman_of_committee = db.Column(
db.Integer, db.ForeignKey("project_supervisors.id")
)
class TemporaryAvailability(Base):
__tablename__ = "temporary_availabilities"
start_date = db.Column(db.DateTime, nullable=False)
end_date = db.Column(db.DateTime, nullable=False)
examination_schedule_id = db.Column(
db.Integer, db.ForeignKey("examination_schedules.id"), nullable=False
)
examination_schedule = db.relationship(
"ExaminationSchedule", backref="temporary_availabilities"
)
project_supervisor_id = db.Column(
db.Integer, db.ForeignKey("project_supervisors.id"), nullable=False
)
project_supervisor = db.relationship(
"ProjectSupervisor", backref="temporary_availabilities"
)