class OD_categories(db.Model):
    __tablename__ = '{db_prefix}_categories'.format(db_prefix=database_prefix)
    category_id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    name = db.Column(db.String(100))

    def __init__(self, name):
        self.name = name
Exemple #2
0
class Subject(db.Model):
    __tablename__ = '{db_prefix}_subject'.format(db_prefix=database_prefix)
    __table_args__ = {'extend_existing': True}
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    code = db.Column(db.String(80))
    name = db.Column(db.Text())
    major = db.Column(db.String(6), nullable=True)
    grade = db.Column(db.Integer)
    weight = db.Column(db.String(4))
    category = db.Column(db.String(8))
    curriculum = db.Column(db.Integer)
    alias = db.Column(db.Text)

    def __init__(self, data=None):
        self.code = data['code']
        self.name = data['name']
        self.major = data['major']
        self.grade = data['grade']
        self.weight = data['weight']
        self.category = data['category']
        self.curriculum = data['curriculum']
        self.alias = data['alias']

    @classmethod
    def get_choices(self):
        subjects = self.query.with_entities(self.id, self.name)
        return subjects
Exemple #3
0
class EclassMemberSchema(db.Model):
    """Eclass member database schema.

    :id integer: The membership id
    :class_id integer: The eclass id
    :user_id integer: The user id
    :is_creator integer: (bool) The creator flag
    """

    __tablename__ = 'eclass_member'
    id = db.Column(db.Integer, primary_key=True, nullable=False)
    class_id = db.Column(db.Integer, nullable=False)
    user_id = db.Column(db.Integer, nullable=False)
    is_creator = db.Column(db.SmallInteger, nullable=False, default=0)
Exemple #4
0
class EclassSchema(db.Model):
    """Eclass database schema

    :id integer: The Eclass id
    :name varchar: The Eclass name
    :course varchar: The course where Eclass belongs to
    :university varchar: The university where Eclass belongs to
    :privilege varchar: The Eclass privilege, public or private
    """

    __tablename__ = 'eclass'
    id = db.Column(db.Integer, primary_key=True, nullable=False)
    name = db.Column(db.VARCHAR(50), nullable=False)
    course = db.Column(db.VARCHAR(50))
    university = db.Column(db.VARCHAR(50))
    privilege = db.Column(db.VARCHAR(8), default="private")
Exemple #5
0
class Setting(db.Model):
    __tablename__ = 'module_employee_site_setting'
    __table_args__ = {'extend_existing': True}
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    name = db.Column(db.Text)

    def serialize(self):
        return {'id': self.id, 'name': self.name}

    def insert(self, data=None):
        self.name = data['name']
        db.session.add(self)
        return db.session.commit()

    def get_existing_name(self):
        setting = self.query.limit(1).first()
        return setting

    def update(self, data):
        setting = self.get_existing_name()
        setting.name = data['name']
        return db.session.commit()
class OD_books(db.Model):
    __tablename__ = '{db_prefix}_books'.format(db_prefix=database_prefix)
    book_id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    isbn = db.Column(db.String(10), unique=True)
    title = db.Column(db.String(100))
    author = db.Column(db.String(100))
    publisher = db.Column(db.String(100))
    price = db.Column(db.String(50))
    category = db.Column(db.String(50))

    def __init__(self, isbn, title, author, publisher, price, category):
        self.isbn = isbn
        self.title = title
        self.author = author
        self.publisher = publisher
        self.price = price
        self.category = category
Exemple #7
0
class EclassPostsSchema(db.Model):
    """Eclass posts database schema.

    :id integer: The Post id
    :class_id integer: The Eclass id
    :description text: The post's description
    :reply text: The post's reply
    :attachment text: The post's file attachment
    :created datetime: Time when The post is created
    :edited datetime: Time when The post is edited
    """

    __tablename__ = 'eclass_discussion'
    id = db.Column(db.Integer, primary_key=True, nullable=False)
    class_id = db.Column(db.Integer, nullable=False)
    description = db.Column(db.Text)
    reply = db.Column(db.UnicodeText())
    attachment = db.Column(db.Text)
    created = db.Column(db.DateTime)
    edited = db.Column(db.DateTime)
Exemple #8
0
class User(db.Model):
    __tablename__ = '{db_prefix}_user'.format(db_prefix=database_prefix)
    __table_args__ = {'extend_existing': True}
    id = db.Column(db.Integer,
                   primary_key=True,
                   autoincrement=True,
                   nullable=False)
    username = db.Column(db.String(16), unique=True)
    password = db.Column(db.Text())
    fullname = db.Column(db.Text())
    nip = db.Column(db.BigInteger())
    access_token = db.Column(db.Text())
    public_key = db.Column(db.Text())
    private_key = db.Column(db.Text())
    status = db.Column(db.Integer)
    created = db.Column(db.DateTime())
    last_login = db.Column(db.DateTime())

    def __init__(self, user=None):
        self.username = user['username']
        self.password = user['password']
        self.fullname = user['fullname']
        self.nip = user['nip']
        self.created = user['created']