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)
class UserAuthority(db.Model, Entity): __tablename__ = 'tm_user_authority' id = db.Column('user_authority_id', db.BigInteger, db.Sequence('tm_user_authority_user_authority_id_seq'), primary_key=True) authority = db.Column(db.String(255)) user_id = db.Column(db.ForeignKey(u'tm_user.user_id'), nullable=False)
class Client(db.Model, Entity): __tablename__ = 'tm_client' id = db.Column('client_oauth_id', db.BigInteger, db.Sequence('tm_client_client_oauth_id_seq'), primary_key=True) client_id = db.Column(db.String(255), unique=True) client_secret = db.Column(db.String(255))
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
class QuestionScore(db.Model, Entity): __tablename__ = 'tm_question_score' id = db.Column('question_score_id', db.BigInteger, db.Sequence('tm_question_score_question_score_id_seq'), primary_key=True) question_id = db.Column(db.ForeignKey('tm_task_question.question_id'), nullable=False) user_id = db.Column(db.ForeignKey(u'tm_user.user_id'), nullable=False) task_id = db.Column(db.ForeignKey(u'tm_task.task_id')) score = db.Column(db.Numeric, nullable=False) user_answer = db.Column(db.Text, nullable=False, server_default='') __table_args__ = (db.UniqueConstraint( 'user_id', 'question_id', name='uix_question_score_question_id_user_id'), ) def __init__(self, obj=None): Entity.__init__(self, obj)
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()
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)
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)