Beispiel #1
0
class Type(Base):
    __tablename__ = 'types'

    name = db.Column(db.String(100), nullable=False)
    nodes = db.relationship('Node',
                            lazy='select',
                            backref=db.backref('type', lazy='joined'))

    def __init__(self, type_name):
        self.name = type_name

    def __repr__(self):
        return '<Type %r>' % (self.name)
Beispiel #2
0
class Subject(Base):
    __tablename__ = 'subjects'

    name = db.Column(db.String(120), nullable=False)
    prerequisite = db.Column(db.Integer, nullable=False)
    minimum_approved = db.Column(db.Integer, nullable=False)
    nodes = db.relationship('Node',
                            lazy='select',
                            backref=db.backref('subject', lazy='joined'))

    def __init__(self, name, prerequisite, minimum):
        self.name = name
        self.prerequisite = prerequisite
        self.minimum_approved = minimum

    def __repr__(self):
        return '<Subject %r>' % (self.name)
Beispiel #3
0
class User(Base):
    __tablename__ = 'users'

    name = db.Column(db.String(150), nullable=False)
    email = db.Column(db.String(250), nullable=False, unique=True)
    password = db.Column(db.String(250), nullable=False)
    approved = db.relationship('Subject',
                               secondary=subjects_approved,
                               lazy='subquery',
                               backref=db.backref('users', lazy=True))

    def __init__(self, name, email, password):
        self.name = name
        self.email = email
        self.password = password

    def __repr__(self):
        return '<User %r>' % (self.email)