class Evaluation(db.Model): __tablename__ = "evaluations" id = db.Column("id", db.Integer, primary_key=True, autoincrement=True) type = db.Column("type", db.Enum(EvaluationTypeEnum), nullable=False) year = db.Column("year", db.Integer, nullable=False) period = db.Column("period", db.Enum(PeriodEnum), nullable=False) evaluation_key_id = db.Column( "evaluation_key_id", db.Integer, db.ForeignKey("evaluation_keys.id", onupdate="CASCADE", ondelete="CASCADE"), nullable=False, ) download_link = db.Column("download_link", db.Unicode(), nullable=False) subject_id = db.Column("subject_id", db.Integer, db.ForeignKey("subjects.id", ondelete="CASCADE", onupdate="CASCADE"), nullable=False) created_at = db.Column("created_at", db.DateTime(), server_default=db.func.now()) updated_at = db.Column("updated_at", db.DateTime(), server_default=db.func.now(), onupdate=db.func.now()) evaluation_key = db.relationship(EvaluationKey, backref="evaluation") subject = db.relationship(Subject, backref="evaluation") def save(self): db.session.add(self) db.session.commit() def __repr__(self): return (f"<Evaluation: " f"id: {self.id}, " f"type: {self.type}, " f"year: {self.year}, " f"period: {self.period}, " f"evaluation_key_id: {self.evaluation_key_id}, " f"download_link: {self.download_link}, " f"subject_id: {self.subject_id}" f">") def __str__(self): return f"{self.subject.name}_{self.year}.{self.period}_{self.type}"
class LessonData(db.Model): __tablename__ = "lesson_data" id = db.Column("id", db.Integer, primary_key=True, autoincrement=True) raw_xml = db.Column("xml_raw_data", db.Text) json_xml = db.Column("json_xml", db.JSON) raw_index = db.Column("raw_index", db.Text) json_index = db.Column("json_index", db.JSON) raw_sync = db.Column("raw_sync", db.Text) json_sync = db.Column("json_sync", db.JSON) lesson_id = db.Column( "lesson_id", db.Integer, db.ForeignKey("lessons.id", ondelete="CASCADE", onupdate="CASCADE"), nullable=False, unique=True, ) created_at = db.Column("created_at", db.DateTime(), server_default=db.func.now()) updated_at = db.Column("updated_at", db.DateTime(), server_default=db.func.now(), onupdate=db.func.now()) lesson = db.relationship(Lesson, backref="LessonData")
class ProfessorSubject(db.Model): __tablename__ = "professors_subjects" subject_id = db.Column( "subject_id", db.Integer, db.ForeignKey("subjects.id", onupdate="CASCADE"), primary_key=True ) professor_id = db.Column( "professor_id", db.Integer, db.ForeignKey("professors.id", ondelete="SET NULL", onupdate="CASCADE"), primary_key=True, ) subject = db.relationship(Subject, backref="professor_subject") professor = db.relationship(Professor, backref="professor_subject") def save(self): db.session.add(self) db.session.commit() def __repr__(self): return f"<ProfessorSubject: " f"subject: {self.subject.name}, " f"professor: {self.professor.name}" f">"