Ejemplo n.º 1
0
class TeachingLesson(DB.Model):
    """Класс для сущности 'Учебное занятие'"""
    __tablename__ = 'teaching_lesson'

    teaching_lesson_id = DB.Column(DB.INTEGER, primary_key=True, autoincrement=True)
    schedule = DB.Column(DB.JSON, nullable=False)
    lesson_type = DB.Column(DB.Enum(LessonType), nullable=False)

    curriculum_units = DB.relationship(
        'CurriculumUnit', secondary='teaching_lesson_and_curriculum_unit'
    )

    def __repr__(self):
        return "TeachingLesson(teaching_lesson_id={teaching_lesson_id}," \
               " schedule={schedule}," \
               " lesson_type={lesson_type})" \
            .format(teaching_lesson_id=self.teaching_lesson_id,
                    schedule=self.schedule,
                    lesson_type=self.lesson_type)
Ejemplo n.º 2
0
class CurriculumUnit(DB.Model):
    """Класс для сущности 'Единица учебного плана'"""
    __tablename__ = 'curriculum_unit'
    __table_args__ = (
        DB.UniqueConstraint('subject_id', 'stud_group_id'),
    )

    id = DB.Column('curriculum_unit_id', DB.INTEGER, primary_key=True, autoincrement=True)
    subject_id = DB.Column(DB.ForeignKey('subject.subject_id'), nullable=False, index=True)
    stud_group_id = DB.Column(DB.ForeignKey('stud_group.stud_group_id'), nullable=False, index=True)
    teacher_id = DB.Column(DB.ForeignKey('teacher.teacher_id'), nullable=False, index=True)
    mark_type = DB.Column('mark_type', DB.Enum(MarkType), nullable=False)
    hours_att_1 = DB.Column('hours_att_1', DB.SMALLINT, nullable=False)
    hours_att_2 = DB.Column('hours_att_2', DB.SMALLINT, nullable=False)
    hours_att_3 = DB.Column('hours_att_3', DB.SMALLINT, nullable=False)

    subject = DB.relationship('Subject')
    teacher = DB.relationship('Teacher')
    att_marks = DB.relationship('AttMark', lazy=True, backref='curriculum_unit')
    teaching_lessons = DB.relationship(
        'TeachingLesson', secondary='teaching_lesson_and_curriculum_unit'
    )

    def __repr__(self):
        return "CurriculumUnit(id={id}, subject_id={subject_id}, stud_group_id={stud_group_id}," \
               " teacher_id={teacher_id}," \
               " mark_type={mark_type}, hours_att_1={hours_att_1}," \
               " hours_att_2={hours_att_2}," \
               " hours_att_3={hours_att_3})" \
            .format(id=self.id,
                    subject_id=self.subject_id,
                    stud_group_id=self.stud_group_id,
                    teacher_id=self.teacher_id,
                    mark_type=self.mark_type,
                    hours_att_1=self.hours_att_1,
                    hours_att_2=self.hours_att_2,
                    hours_att_3=self.hours_att_3)