Beispiel #1
0
class Course(db.Model):
    __tablename__ = "courses"
    __table_args__ = {"extend_existing": True}
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(64), unique=True, index=True)
    description = db.Column(db.String(64))

    def __repr__(self):
        return '<Course {name}>'.format(name=self.name)

    def get_id(self):
        return self.id
Beispiel #2
0
class Group(db.Model):
    __tablename__ = "groups"
    __table_args__ = {"extend_existing": True}
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(64), index=True, unique=True)
    department = db.String(64)
    students = db.relationship('Student', backref='group', lazy='dynamic')

    def __repr__(self):
        return "<Group {}>".format(self.name)

    def get_id(self):
        return self.id
Beispiel #3
0
class Schedule(db.Model):
    __tablename__ = "schedule"
    __table_args__ = {"extend_existing": True}
    id = db.Column(db.Integer, primary_key=True)
    course_id = db.Column(db.Integer, db.ForeignKey('courses.id'))
    group_id = db.Column(db.Integer, db.ForeignKey('groups.id'))

    def __repr__(self):
        return '| {course} - {group} |'.format(course=self.get_course(),
                                               group=self.get_group())

    def get_group(self):
        return Group.query.filter_by(id=self.group_id).first()

    def get_course(self):
        return Course.query.filter_by(id=self.course_id).first()
Beispiel #4
0
class Student(db.Model):
    __tablename__ = "students"
    __table_args__ = {"extend_existing": True}
    id = db.Column(db.Integer, primary_key=True)
    user_id = db.Column(db.Integer, db.ForeignKey('users.id'))
    group_id = db.Column(db.Integer, db.ForeignKey('groups.id'))
    year = db.Column(db.Integer)
    degree = db.Column(db.String(64))
    education_form = db.Column(db.String(64))
    education_basis = db.Column(db.String(64))

    def __repr__(self):
        return 'User_id: {user_id}, Учебная группа: {group}, ' \
                'Год поступления: {year}, Степень: {degree}, ' \
               'Форма обучения: {education}, Основа обучения: {basis} |'.format(
                   group=self.get_group(), year=self.year,
                   degree=self.degree, education=self.education_form,
                   basis=self.education_basis, user_id=self.user_id)

    def get_group(self):
        return Group.query.filter_by(id=self.group_id).first()

    def get_group_id(self):
        return self.group_id

    def get_id(self):
        return self.id
Beispiel #5
0
class Teacher(db.Model):
    __tablename__ = "teachers"
    __table_args__ = {"extend_existing": True}
    id = db.Column(db.Integer, primary_key=True)
    user_id = db.Column(db.Integer, db.ForeignKey('users.id'))