Exemplo n.º 1
0
class Base(db.Model):
    __abstract__ = True

    id            = db.Column(db.Integer, primary_key = True, autoincrement = True)
    date_created  = db.Column(db.DateTime, default  = db.func.current_timestamp())
    date_modified = db.Column(db.DateTime, default  = db.func.current_timestamp(),
                                           onupdate = db.func.current_timestamp())
Exemplo n.º 2
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)
Exemplo n.º 3
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)
Exemplo n.º 4
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)
Exemplo n.º 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)
Exemplo n.º 6
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)
Exemplo n.º 7
0
from app.handlers import db

subjects_approved = db.Table(
    'user_subjects_approved',
    db.Column('user_id',
              db.Integer,
              db.ForeignKey('users.id'),
              primary_key=True),
    db.Column('subject_id',
              db.Integer,
              db.ForeignKey('subjects.id'),
              primary_key=True))


class Base(db.Model):
    __abstract__ = True

    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    date_created = db.Column(db.DateTime, default=db.func.current_timestamp())
    date_modified = db.Column(db.DateTime,
                              default=db.func.current_timestamp(),
                              onupdate=db.func.current_timestamp())


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',