Ejemplo n.º 1
0
class Lesson(db.Model, Entity):
    __tablename__ = 'tm_lesson'
    id = db.Column('lesson_id',
                   db.BigInteger,
                   db.Sequence('tm_lesson_lesson_id_seq'),
                   primary_key=True)
    title = db.Column(db.String(140), nullable=False)
    type = db.Column(db.String(20), nullable=False, default='video')
    document_id = db.Column(db.ForeignKey(u'tm_document.document_id'),
                            nullable=False,
                            index=True)
    price = db.Column(db.Numeric, nullable=False)
    user_id = db.Column(db.ForeignKey(u'tm_user.user_id'),
                        nullable=False,
                        index=True)
    topic_id = db.Column(db.ForeignKey(u'tm_topic.topic_id'), index=True)
    user = db.relationship(u'UserPrincipal')
    active = db.Column(db.String, nullable=False, server_default='I')
    created_at = db.Column(db.DateTime(timezone=False), default=datetime.now)
    update_at = db.Column(db.DateTime(timezone=False), onupdate=datetime.now)
    # Hiding the json key in http get
    __json_hidden__ = [
        'user.hash_password', 'user.account_non_expired',
        'user.credentials_non_expired', 'user.account_non_locked'
    ]

    def __init__(self, obj=None):
        Entity.__init__(self, obj)
Ejemplo n.º 2
0
class SchoolLevel(db.Model, Entity):
    __tablename__ = 'tm_school_level'
    id = db.Column('school_level_id',
                   db.BigInteger,
                   db.Sequence('tm_school_level_school_level_id_seq'),
                   primary_key=True)
    name = db.Column(db.String(30), nullable=False, index=True)
    sort_number = db.Column(db.BigInteger, nullable=False)
    created_at = db.Column(db.DateTime(timezone=False), default=datetime.now)
    update_at = db.Column(db.DateTime(timezone=False), onupdate=datetime.now)
Ejemplo n.º 3
0
class TaskGroup(db.Model, Entity):
    __tablename__ = 'tm_task_group'
    task_id = db.Column(db.ForeignKey(u'tm_task.task_id'),
                        nullable=False,
                        primary_key=True)
    group_id = db.Column(db.ForeignKey(u'tm_learning_group.group_id'),
                         nullable=False,
                         primary_key=True)
    created_at = db.Column(db.DateTime(timezone=False), default=datetime.now)
    update_at = db.Column(db.DateTime(timezone=False), onupdate=datetime.now)

    def __init__(self, obj=None):
        Entity.__init__(self, obj)
Ejemplo n.º 4
0
class TaskAnswer(db.Model, Entity):
    __tablename__ = "tm_task_answer"
    id = db.Column('answer_id',
                   db.BigInteger,
                   db.Sequence('tm_task_answer_answer_id_seq'),
                   primary_key=True)
    question_id = db.Column(db.ForeignKey(u'tm_task_question.question_id'),
                            nullable=False)
    answer = db.Column(db.Text, nullable=False, server_default='')
    created_at = db.Column(db.DateTime(timezone=False), default=datetime.now)
    update_at = db.Column(db.DateTime(timezone=False), onupdate=datetime.now)

    def __init__(self, obj=None):
        Entity.__init__(self, obj)
Ejemplo n.º 5
0
class LessonViewer(db.Model, Entity):
    __tablename__ = 'tm_lesson_viewer'
    user_id = db.Column(db.ForeignKey(u'tm_user.user_id'),
                        nullable=False,
                        primary_key=True)
    lesson_id = db.Column(db.ForeignKey(u'tm_lesson.lesson_id'),
                          nullable=False,
                          primary_key=True)

    created_at = db.Column(db.DateTime(timezone=False), default=datetime.now)
    update_at = db.Column(db.DateTime(timezone=False), onupdate=datetime.now)

    def __init__(self, obj=None):
        Entity.__init__(self, obj)
Ejemplo n.º 6
0
class Friend(db.Model, Entity):
    __tablename__ = 'tm_friend'
    user_id = db.Column(db.ForeignKey(u'tm_user.user_id'),
                        nullable=False,
                        primary_key=True)
    friend_id = db.Column(db.ForeignKey(u'tm_user.user_id'),
                          nullable=False,
                          primary_key=True)
    status = db.Column(db.String(10), nullable=False, server_default='')
    created_at = db.Column(db.DateTime(timezone=False), default=datetime.now)
    update_at = db.Column(db.DateTime(timezone=False), onupdate=datetime.now)

    def __init__(self, obj=None):
        Entity.__init__(self, obj)
Ejemplo n.º 7
0
class SchoolClass(db.Model, Entity):
    __tablename__ = 'tm_school_class'
    id = db.Column('school_class_id',
                   db.BigInteger,
                   db.Sequence('tm_school_class_school_class_id_seq'),
                   primary_key=True)
    name = db.Column(db.String(30), nullable=False, index=True)
    level_id = db.Column(db.ForeignKey(u'tm_school_level.school_level_id'),
                         index=True)
    created_at = db.Column(db.DateTime(timezone=False), default=datetime.now)
    update_at = db.Column(db.DateTime(timezone=False), onupdate=datetime.now)

    def __init__(self, obj=None):
        Entity.__init__(self, obj)
Ejemplo n.º 8
0
class Address(db.Model, Entity):
    __tablename__ = 'tm_address'
    id = db.Column('address_id',
                   db.BigInteger,
                   db.Sequence('tm_address_address_id_seq'),
                   primary_key=True)
    address = db.Column(db.Text)
    latitude = db.Column(db.BigInteger, default=-1)
    longitude = db.Column(db.BigInteger, default=-1)
    created_at = db.Column(db.DateTime(timezone=False), default=datetime.now)
    update_at = db.Column(db.DateTime(timezone=False), onupdate=datetime.now)

    def __init__(self, obj=None):
        Entity.__init__(self, obj)
Ejemplo n.º 9
0
class Task(db.Model, Entity):
    __tablename__ = 'tm_task'
    id = db.Column('task_id',
                   db.BigInteger,
                   db.Sequence('tm_task_task_id_seq'),
                   primary_key=True)
    title = db.Column(db.Text, nullable=False)
    user_id = db.Column(db.ForeignKey(u'tm_user.user_id'), nullable=False)
    active = db.Column(db.Boolean, nullable=False, default=True)
    time_limit = db.Column(db.BigInteger, nullable=False, default=0)
    created_at = db.Column(db.DateTime(timezone=False), default=datetime.now)
    update_at = db.Column(db.DateTime(timezone=False), onupdate=datetime.now)

    def __init__(self, obj=None):
        Entity.__init__(self, obj)
Ejemplo n.º 10
0
class LearningGroup(db.Model, Entity):
    __tablename__ = "tm_learning_group"
    id = db.Column('group_id',
                   db.BigInteger,
                   db.Sequence('tm_learning_group_group_id_seq'),
                   primary_key=True)
    name = db.Column(db.String(120))
    user_id = db.Column(db.ForeignKey(u'tm_user.user_id'), nullable=False)
    document_id = db.Column(db.ForeignKey(u'tm_document.document_id'),
                            index=True)
    created_at = db.Column(db.DateTime(timezone=False), default=datetime.now)
    update_at = db.Column(db.DateTime(timezone=False), onupdate=datetime.now)

    def __init__(self, obj=None):
        Entity.__init__(self, obj)
Ejemplo n.º 11
0
class TaskScore(db.Model, Entity):
    __tablename__ = 'tm_task_score'
    id = db.Column('task_score_id',
                   db.BigInteger,
                   db.Sequence('tm_task_score_task_score_id_seq'),
                   primary_key=True)
    task_id = db.Column(db.ForeignKey(u'tm_task.task_id'), nullable=False)
    user_id = db.Column(db.ForeignKey(u'tm_user.user_id'), nullable=False)
    score = db.Column(db.Numeric, nullable=False)
    __table_args__ = (db.UniqueConstraint(
        'user_id', 'task_id', name='uix_task_score_task_id_user_id'), )
    created_at = db.Column(db.DateTime(timezone=False), default=datetime.now)
    update_at = db.Column(db.DateTime(timezone=False), onupdate=datetime.now)

    def __init__(self, obj=None):
        Entity.__init__(self, obj)
Ejemplo n.º 12
0
class TaskQuestion(db.Model, Entity):
    __tablename__ = 'tm_task_question'
    id = db.Column('question_id',
                   db.BigInteger,
                   db.Sequence('tm_task_question_question_id_seq'),
                   primary_key=True)
    task_id = db.Column(db.ForeignKey(u'tm_task.task_id'), nullable=False)
    question = db.Column(db.Text, nullable=False, server_default='')
    question_type = db.Column(db.String(10), nullable=False, server_default='')
    answer_key = db.Column(db.Text, nullable=False, server_default='')
    answers = db.relationship(u'TaskAnswer')
    created_at = db.Column(db.DateTime(timezone=False), default=datetime.now)
    update_at = db.Column(db.DateTime(timezone=False), onupdate=datetime.now)

    def __init__(self, obj=None):
        Entity.__init__(self, obj)
Ejemplo n.º 13
0
class Document(db.Model, Entity):
    __tablename__ = 'tm_document'
    id = db.Column('document_id',
                   db.BigInteger,
                   db.Sequence('tm_document_document_id_seq'),
                   primary_key=True)
    filename = db.Column(db.Text, nullable=False)
    original_filename = db.Column(db.Text, nullable=False, server_default='')
    thumbnails = db.Column(db.Text)
    mimetype = db.Column(db.String(60), nullable=False)
    folder = db.Column(db.Text, nullable=False)
    secure = db.Column(db.Boolean, nullable=False, server_default='t')
    created_at = db.Column(db.DateTime(timezone=False), default=datetime.now)
    update_at = db.Column(db.DateTime(timezone=False), onupdate=datetime.now)

    def __init__(self, obj=None):
        Entity.__init__(self, obj)
Ejemplo n.º 14
0
class Notification(db.Model, Entity):
    __tablename__ = 'tm_notification'
    id = db.Column('notification_id',
                   db.BigInteger,
                   db.Sequence('tm_notification_notification_id_seq'),
                   primary_key=True)
    user_id = db.Column(db.ForeignKey(u'tm_user.user_id'), nullable=False)
    message = db.Column(db.String(60), nullable=False)
    title = db.Column(db.String(60), nullable=False)
    text = db.Column(db.Text, nullable=False)
    sent = db.Column(db.Boolean, nullable=False, server_default='f')

    created_at = db.Column(db.DateTime(timezone=False), default=datetime.now)
    update_at = db.Column(db.DateTime(timezone=False), onupdate=datetime.now)

    def __init__(self, obj=None):
        Entity.__init__(self, obj)
Ejemplo n.º 15
0
class UserPrincipal(db.Model, Entity):
    __tablename__ = 'tm_user'
    id = db.Column('user_id',
                   db.BigInteger,
                   db.Sequence('tm_user_user_id_seq'),
                   primary_key=True)
    document_id = db.Column(db.ForeignKey(u'tm_document.document_id'),
                            index=True)
    phone_number = db.Column(db.String(20), nullable=False, unique=True)
    username = db.Column(db.String(60), nullable=False, unique=True)
    fullname = db.Column(db.String(100), nullable=False)
    gender = db.Column(db.String(1), nullable=False)
    hash_password = db.Column(db.LargeBinary(60), nullable=False)
    address_id = db.Column(db.ForeignKey(u'tm_address.address_id'),
                           nullable=True,
                           index=True)
    enabled = db.Column(db.Boolean, nullable=False, default=False)
    account_non_expired = db.Column(db.Boolean, nullable=False, default=False)
    account_non_locked = db.Column(db.Boolean, nullable=False, default=False)
    credentials_non_expired = db.Column(db.Boolean,
                                        nullable=False,
                                        default=False)
    register_type = db.Column(db.String(20),
                              nullable=False,
                              default='',
                              server_default='')
    class_id = db.Column(db.ForeignKey(u'tm_school_class.school_class_id'),
                         index=True)
    level_id = db.Column(db.ForeignKey(u'tm_school_level.school_level_id'),
                         index=True)
    created_at = db.Column(db.DateTime(timezone=False), default=datetime.now)
    update_at = db.Column(db.DateTime(timezone=False), onupdate=datetime.now)
    __json_hidden__ = [
        'hash_password', 'enabled', 'account_non_expired',
        'account_non_locked', 'credentials_non_expired'
    ]

    def __init__(self, obj=None):
        Entity.__init__(self, obj)

    def to_dict(self):
        return super().to_dict()
Ejemplo n.º 16
0
class LessonComment(db.Model, Entity):
    __tablename__ = 'tm_lesson_comment'
    id = db.Column('lesson_comment_id',
                   db.BigInteger,
                   db.Sequence('tmlesson_comment_lesson_comment_id_seq'),
                   primary_key=True)
    sender_user_id = db.Column(db.ForeignKey(u'tm_user.user_id'),
                               nullable=False)
    lesson_id = db.Column(db.ForeignKey(u'tm_lesson.lesson_id'),
                          nullable=False)
    message = db.Column(db.Text, nullable=False)
    created_at = db.Column(db.DateTime(timezone=False), default=datetime.now)
    update_at = db.Column(db.DateTime(timezone=False), onupdate=datetime.now)
    user = db.relationship(u'UserPrincipal')
    __json_hidden__ = [
        'user.hash_password', 'user.account_non_expired',
        'user.credentials_non_expired', 'user.account_non_locked'
    ]

    def __init__(self, obj=None):
        Entity.__init__(self, obj)
Ejemplo n.º 17
0
class Activity(db.Model, Entity):
    __tablename__ = 'tm_activity'
    id = db.Column('activity_id',
                   db.BigInteger,
                   db.Sequence('tm_activity_activity_id_seq'),
                   primary_key=True)
    message = db.Column(db.Text, nullable=False)
    user_id = db.Column(db.ForeignKey(u'tm_user.user_id'),
                        nullable=False,
                        index=True)
    raw = db.Column(db.Text, nullable=False, server_default='-', default='')
    created_at = db.Column(db.DateTime(timezone=False), default=datetime.now)
    update_at = db.Column(db.DateTime(timezone=False), onupdate=datetime.now)
    user = db.relationship(u'UserPrincipal')
    doc_type = db.Column(db.String(20))
    __json_hidden__ = [
        'user.hash_password', 'user.account_non_expired',
        'user.credentials_non_expired', 'user.account_non_locked'
    ]

    def __init__(self, obj=None):
        Entity.__init__(self, obj)