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 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 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">"
class Professor(db.Model): __tablename__ = "professors" id = db.Column("id", db.Integer, primary_key=True, autoincrement=True) name = db.Column("name", db.Unicode(70), nullable=False) email = db.Column("email", db.Unicode(100)) site = db.Column("site", db.Unicode()) 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()) def save(self): db.session.add(self) db.session.commit() def __repr__(self): return (f"<Professor: " f"id: {self.id}, " f"name: {self.name}, " f"email: {self.email}, " f"site: {self.site}" f">") def __str__(self): return self.name
class EvaluationKey(db.Model): __tablename__ = "evaluation_keys" id = db.Column("id", db.Integer, primary_key=True, autoincrement=True) description = db.Column("description", db.Unicode(45), 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()) def save(self): db.session.add(self) db.session.commit() def __repr__(self): return f"<EvaluationKey: " f"id: {self.id}, " f"description: {self.description}" f">" def __str__(self): return self.description
class Subject(db.Model): __tablename__ = "subjects" id = db.Column("id", db.Integer, primary_key=True, autoincrement=True) code = db.Column("code", db.Unicode(8), unique=True, nullable=False) name = db.Column("name", db.Unicode(70), nullable=False) type = db.Column("type", db.Enum(SubjectTypeEnum), nullable=False) workload = db.Column("workload", db.Integer, nullable=False) amount_lessons = db.Column("amount_lessons", db.Integer, nullable=False, default=0) drive_link = db.Column("drive_link", db.Unicode()) whatsapp_link = db.Column("whatsapp_link", db.Unicode()) telegram_link = db.Column("telegram_link", db.Unicode()) github_link = db.Column("github_link", db.Unicode()) material_design_icon = db.Column("material_design_icon", db.Unicode()) 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()) def save(self): db.session.add(self) db.session.commit() def __repr__(self): return f"<Subject: {self.name}, " f"code: {self.code}" f">"