示例#1
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)
示例#2
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)
示例#3
0
class Assistant(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    firstname = db.Column(db.String(60), nullable=False)
    lastname = db.Column(db.String(60), nullable=False)
    email = db.Column(db.String(80), nullable=False)
    occupation = db.Column(db.Text, nullable=False)
    creationdate = db.Column(db.String(20), nullable=False)
    filename = db.Column(db.String(100))
    modificationdate = db.Column(db.String(30), nullable=True)
示例#4
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)
示例#5
0
class Node(Base):
    __tablename__ = 'nodes'

    answer_parent = db.Column(db.String(250), nullable=False)
    parent_node = db.Column(db.Integer, nullable=False)
    score = db.Column(db.Integer, nullable=False)
    type_id = db.Column(db.Integer, db.ForeignKey('types.id'), nullable=False)
    subject_id = db.Column(db.Integer,
                           db.ForeignKey('subjects.id'),
                           nullable=False)

    def __init__(self, answer, parent, score):
        self.answer_parent = answer
        self.parent_node = parent
        self.score = score

    def __repr__(self):
        return '<Node %d>' % (self.id)