from ..dependencies import db from ..base.models import Base 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 start_date_for_enrollment_students = db.Column(db.DateTime) end_date_for_enrollment_students = db.Column(db.DateTime) 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') members_of_committee = db.relationship("ProjectSupervisor", secondary=committee) 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')