Exemplo n.º 1
0
class ContactTagsDetails(CommonModel):
    __tablename__ = 'contact_tags_details'
    contact_tags_id = db.Column(UUID(as_uuid=True), ForeignKey("contact_tags.id", onupdate="CASCADE", ondelete="CASCADE"), nullable=False)
    contact_id = db.Column(UUID(as_uuid=True), ForeignKey("contact.id", onupdate="CASCADE", ondelete="CASCADE"), nullable=False)
    timestamp = db.Column(BigInteger)
    description = db.Column(Text())
    tenant_id = db.Column(String(), ForeignKey("tenant.id", onupdate="CASCADE", ondelete="RESTRICT"), nullable=False)
Exemplo n.º 2
0
class DanToc(CommonModel):
    __tablename__ = 'dantoc'
    id = db.Column(String, primary_key=True, default=default_uuid)
    ma = db.Column(String(255), index=True)
    ten = db.Column(String(255))
    tenkhongdau = db.Column(String)
    active = db.Column(SmallInteger(), default=0)
Exemplo n.º 3
0
class Task(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    content = db.Column(db.String(200), nullable=False)
    date_created = db.Column(db.DateTime, default=datetime.utcnow)

    def __repr__(self):
        return f"Post('{self.id}','{self.content}','{self.date_created}')"
Exemplo n.º 4
0
class QuanHuyen(CommonModel):
    __tablename__ = 'quanhuyen'
    id = db.Column(db.Integer, primary_key=True)
    ma = db.Column(db.String(255), unique=True)
    ten = db.Column(db.String(255), nullable=False)
    tinhthanh_id = db.Column(db.Integer, db.ForeignKey('tinhthanh.id'), nullable=True)
    tinhthanh = db.relationship('TinhThanh',viewonly=True)
Exemplo n.º 5
0
class BaoCaoNghiNgoNhiemBenhQuocGia(CommonModel):
    __tablename__ = 'baocaonghingonhiembenhquocgia'
    id = db.Column(db.Integer, primary_key=True)
    baocao_id = db.Column(db.Integer,db.ForeignKey('baocaonghingonhiembenh.id'), nullable=True)
    baocao = db.relationship('BaoCaoNghiNgoNhiemBenh', backref=db.backref('baocaonghingonhiembenhquocgia',lazy='dynamic'))
    tenquocgia = db.Column(db.String())
    ngaydiqua = db.Column(db.DateTime())
Exemplo n.º 6
0
class CommonModel(db.Model):
    __abstract__ = True
    id = db.Column(Integer, primary_key=True, default=default_uuid)
    created_at = db.Column(DateTime)
    updated_at = db.Column(DateTime)
    deleted = db.Column(Boolean, default=False)
    deleted_at = db.Column(DateTime)
Exemplo n.º 7
0
class User(CommonModel):
    __tablename__ = 'user'
    id = db.Column(String, primary_key=True, default=default_uuid)
    name = db.Column(String())
    unsigned_name = db.Column(String())
    email = db.Column(String(255))
    phone = db.Column(String())
    password = db.Column(String(255))
    accountName = db.Column(String(255))
    salt = db.Column(String())

    active = db.Column(SmallInteger(), default=0)
    #0- chua active, 1- active
    # confirmed_at = db.Column(DateTime())
    # type_confirm = db.Column(SmallInteger())
    #0 - email, 1- sms
    roles = relationship("Role", secondary=roles_users)

    organization_id = db.Column(String,
                                ForeignKey('organization.id',
                                           onupdate='CASCADE',
                                           ondelete='SET NULL'),
                                nullable=True)
    Organization = relationship('Organization')

    # Methods
    def __repr__(self):
        """ Show user object info. """
        return '<User: {}>'.format(self.id)

    def has_role(self, role):
        if isinstance(role, str):
            return role in (role.name for role in self.roles)
        else:
            return role in self.roles
Exemplo n.º 8
0
class Template(db.Model):
    """Шаблоны"""
    __bind_key__ = 'caesar'
    __tablename__ = '%s_template' % TABLE_PREFIX

    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    name = db.Column(db.Unicode(80), unique=True, nullable=False)
    archive = db.Column(db.Boolean, default=False)
    is_active = db.Column(db.Boolean, default=False)

    #user = db.Column(db.Integer, db.ForeignKey('.id'))
    type_id = db.Column(db.Integer,
                        db.ForeignKey('%s_template_type.id' % TABLE_PREFIX),
                        index=True)
    type = db.relation(TemplateType)

    tag_tree = db.relationship('TagsTree',
                               backref='template',
                               cascade="all, delete, delete-orphan")

    def __repr__(self):
        return '<Template %r>' % self.name

    def __unicode__(self):
        return self.name
Exemplo n.º 9
0
class Notify(CommonModel):
    __tablename__ = 'notify'
    target = db.Column(String(20))
    action = db.Column(String(16))
    api_path = db.Column(String(255))
    message = db.Column(Text())
    
Exemplo n.º 10
0
class HangHoa(CommonModel):
    __tablename__ = 'hanghoa'
    id = db.Column(Integer, primary_key=True)
    ma = db.Column(String(255), unique=True)
    ten = db.Column(String(255), nullable=False)
    gia = db.Column(Integer)
    ghichu = db.Column(String(255))
Exemplo n.º 11
0
class Test(db.Model):
    __tablename__ = "test"
    id = db.Column(UUID(as_uuid=True), primary_key=True)
    name = db.Column(String(50))
    image = db.Column(String(255))
    price = db.Column(DECIMAL(10, 2))
    describe = db.Column(Text())
Exemplo n.º 12
0
class Permission(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    description = db.Column(db.String(200))

    def __init__(self, id, description):
        self.id = id
        self.description = description
Exemplo n.º 13
0
class Province(CommonModel):
    __tablename__ = 'province'
    id = db.Column(UUID(as_uuid=True), primary_key=True, default=default_uuid)
    code = db.Column(String(255), unique=True, index=True)
    name = db.Column(String(255))
    nation_id = db.Column(UUID(as_uuid=True), ForeignKey('nation.id'))
    nation = relationship('Nation', viewonly=True)
Exemplo n.º 14
0
class TagsTree(db.Model):
    """Древовидная структура тегов"""
    __bind_key__ = 'caesar'
    __tablename__ = '%s_tags_tree' % TABLE_PREFIX

    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    tag_id = db.Column(db.Integer,
                       db.ForeignKey('%s_tag.id' % TABLE_PREFIX),
                       index=True)
    parent_id = db.Column(db.Integer,
                          db.ForeignKey('%s.id' % __tablename__),
                          index=True)
    template_id = db.Column(db.Integer,
                            db.ForeignKey('%s_template.id' % TABLE_PREFIX),
                            nullable=False,
                            index=True)
    ordernum = db.Column(db.Integer, doc=u'Поле для сортировки тегов')

    tag = db.relationship(Tag)
    parent = db.relationship('TagsTree',
                             remote_side=[id],
                             backref=db.backref('children', order_by=ordernum))
    # template = db.relationship(Template)

    __table_args__ = {'order_by': ordernum}

    def __unicode__(self):
        return self.tag.code
Exemplo n.º 15
0
class TinhThanh(CommonModel):
    __tablename__ = 'tinhthanh'
    id = db.Column(Integer, primary_key=True)
    ma = db.Column(String(255), unique=True)
    ten = db.Column(String(255), nullable=False)
    quocgia_id = db.Column(Integer, ForeignKey('quocgia.id'), nullable=False)
    quocgia = db.relationship('QuocGia')
Exemplo n.º 16
0
class Client(Abstract):
    """ Client model class"""
    name = db.Column(db.Text, nullable=False)
    slug = db.Column(db.String(200))

    def __repr__(self):
        return f'<Client: {self.name}>'
Exemplo n.º 17
0
class HoatDongBCCXaThon(CommonModel):
    __tablename__ = 'hoatdongbccxathon'
    id = db.Column(UUID(as_uuid=True), primary_key=True, default=default_uuid)
    hopcapxa = db.Column(db.String)
    camketdat = db.Column(db.String)
    vesinh_thuongxuyen = db.Column(db.String)
    truyenthong_thon = db.Column(db.String)
Exemplo n.º 18
0
class Currency(CommonModel):
    __tablename__ = 'currency'
    id = db.Column(UUID(as_uuid=True), primary_key=True, default=default_uuid)
    currency_name = db.Column(String(50), unique=True, nullable=True)
    currency_code = db.Column(String(11), unique=True, nullable=True)
    currency_symbol = db.Column(String(11), nullable=True)
    tenant_id = db.Column(db.String)
Exemplo n.º 19
0
class ProductArea(Abstract):
    """ ProductArea model class"""
    slug = db.Column(db.String(255), nullable=False)
    title = db.Column(db.String(255), nullable=False)

    def __repr__(self):
        return f'<ProductArea: {self.title}>'
Exemplo n.º 20
0
class Wards(CommonModel):
    __tablename__ = 'wards'
    id = db.Column(UUID(as_uuid=True), primary_key=True, default=default_uuid)
    code = db.Column(String(255), unique=True, index=True)
    name = db.Column(String(255))
    district_id = db.Column(UUID(as_uuid=True), ForeignKey('district.id'))
    district = relationship('District', viewonly=True)
Exemplo n.º 21
0
class District(CommonModel):
    __tablename__ = 'district'
    id = db.Column(UUID(as_uuid=True), primary_key=True, default=default_uuid)
    code = db.Column(String(255), unique=True, index=True)
    name = db.Column(String(255))
    province_id = db.Column(UUID(as_uuid=True), ForeignKey('province.id'))
    province = relationship('Province', viewonly=True)
Exemplo n.º 22
0
class Workstation(CommonModel):
    __tablename__ = 'workstation'
    id = db.Column(Integer, primary_key=True)
    id_organization = db.Column(Integer,
                                ForeignKey('organization.id'),
                                nullable=False)
    address = db.Column(String(255))
Exemplo n.º 23
0
class Comment(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    post_id = db.Column(db.Integer, db.ForeignKey("post.id"))
    name = db.Column(db.String(20))
    content = db.Column(db.Text, nullable=False)
    timestamp = db.Column(db.DateTime,
                          index=True,
                          default=datetime.now(get_localzone()))
Exemplo n.º 24
0
class TaskSchedule(CommonModel):
    __tablename__ = 'task_schedule'
    taskschedule_name = db.Column(String())
    # shift_of_day = db.Column(BigInteger()) #2^n
    start_time_working = db.Column(BigInteger(), default=0)
    end_time_working = db.Column(BigInteger(), default=0)
    active = db.Column(SmallInteger, default=1)
    task_scheduledetail = db.relationship('TaskScheduleDetail')
Exemplo n.º 25
0
class Permission(CommonModel):
    __tablename__ = 'permission'
    id = db.Column(UUID(as_uuid=True), primary_key=True, default=default_uuid)
    role_id = db.Column(UUID(as_uuid=True), ForeignKey('role.id'), nullable=False)
    subject = db.Column(String,index=True)
    permission = db.Column(String)
    value = db.Column(Boolean, default=False)
    __table_args__ = (UniqueConstraint('role_id', 'subject', 'permission', name='uq_permission_role_subject_permission'),)
Exemplo n.º 26
0
class Project(db.Model):
    __tablename__ = "Projects"
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    name = db.Column(db.String(100), nullable=False)
    accounts = db.relationship("Account", backref="project", lazy=True)

    def __repr__(self):
        return f"{self.name}"
Exemplo n.º 27
0
class AvatarImage(db.Model):
    __tablename__ = "avatar_image"

    id = db.Column(db.Integer, primary_key=True)
    path = db.Column(db.String(255), unique=True)
    url = db.Column(db.String(255))
    user_id = db.Column(db.Integer, db.ForeignKey("users.id"))
    user = db.relationship("User")
Exemplo n.º 28
0
class NotifyUser(CommonModel):
    __tablename__ = 'notify_user'
    id = db.Column(String, primary_key=True, default=default_uuid)
    user_id = db.Column(String)
    notify_id = db.Column(String, ForeignKey('notify.id'), nullable=True)
    notify = db.relationship('Notify')
    notify_at = db.Column(BigInteger())
    read_at = db.Column(BigInteger())
Exemplo n.º 29
0
class CommonModel(db.Model):
    __abstract__ = True
    id = db.Column(UUID(as_uuid=True), primary_key=True, default=default_uuid)

    _created_at = db.Column(DateTime)
    _updated_at = db.Column(DateTime)
    _deleted = db.Column(Boolean, default=False)
    _deleted_at = db.Column(DateTime)
Exemplo n.º 30
0
class TodoSchedule(CommonModel):
    id = db.Column(Integer, primary_key=True)
    __tablename__ = 'todoschedule'
    start_time_working = db.Column(DateTime)
    end_time_working = db.Column(DateTime)
    todoscheduledetail = db.relationship("TodoScheduleDetail",
                                         cascade="all, delete-orphan",
                                         lazy='dynamic')