예제 #1
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
예제 #2
0
class EmployeeRelTodo(CommonModel):
    id = db.Column(Integer, primary_key=True)
    __tablename__ = 'employee_rel_todo'
    start_time_working = db.Column(DateTime)
    end_time_working = db.Column(DateTime)
    start_time_visible = db.Column(DateTime)
    end_time_visible = db.Column(DateTime)
    todo_schedule_id = db.Column(
        Integer, ForeignKey('todoschedule.id', ondelete="cascade"))
    day_working = db.Column(String())
    time_working = db.Column(String())
    employee_id = db.Column(Integer,
                            ForeignKey('employee.id', ondelete="cascade"),
                            nullable=False)
    employee_name = db.Column(String(50))
    employee = db.relationship("Employee")
    employee_assign_name = db.Column(String(50))
    employee_assign_id = db.Column(Integer)
    employee_assign = db.relationship("Employee")
    todo_id = db.Column(Integer,
                        ForeignKey('todo.id', ondelete="cascade"),
                        nullable=False)
    todo_name = db.Column(String(50))
    todo = db.relationship("Todo")
    status_complete_manager = db.Column(Integer, default=0)
    status_complete_employee = db.Column(Integer, default=0)
예제 #3
0
class Cart(db.Model):
    __tablename__ = "cart"

    id = db.Column(db.Integer, primary_key=True)
    user_id = db.Column(db.Integer, db.ForeignKey("users.id"))
    user = db.relationship("User")
    games = db.relationship("Game", secondary=cart_game, lazy="dynamic")
예제 #4
0
class Employee(CommonModel):
    id = db.Column(Integer, primary_key=True)
    __tablename__ = 'employee'
    name = db.Column(String(255))
    id_number = db.Column(Integer)
    age = db.Column(Integer)
    hometown = db.Column(String(255))
    phone_number = db.Column(Integer)
    gender = db.Column(String(255))
    position = db.Column(String(255))
    work_place = db.Column(String(255))
    status = db.Column(String(255))
    user_name = db.Column(String(255), nullable=False, index=True)
    full_name = db.Column(String(255), nullable=True)
    email = db.Column(String(255), nullable=False, index=True)
    password = db.Column(String(255), nullable=False)
    parttime_fulltime = db.Column(String(255))
    salary_for_shift = db.Column(Float, default=0)
    salary_for_month = db.Column(Float, default=0)
    employee_schedule = db.relationship("EmployeeSchedule",
                                        cascade="all, delete-orphan",
                                        lazy='dynamic')
    todoscheduledetail = db.relationship(
        "TodoScheduleDetail",
        secondary="employee_rel_todoscheduledetail",
        #backref = db.#backref('employee', lazy = 'dynamic'),
    )
    user = db.relationship("User",
                           cascade="all, delete-orphan",
                           lazy='dynamic')
예제 #5
0
class CuaKhau(CommonModel):
    __tablename__ = 'cuakhau'
    id = db.Column(db.Integer, primary_key=True)
    ma = db.Column(db.String(255), unique=True)
    ten = db.Column(db.String(255), nullable=False)
    #loaicuakhau = db.Column(db.SmallInteger) #
    kiemdichyte = db.Column(db.Boolean, default=True)
    phongcachly = db.Column(db.Boolean, default=True)
    nguoilienlac = db.Column(db.String(255), nullable=True)
    sodienthoai = db.Column(db.String, nullable=True)
    diachi = db.Column(db.String, nullable=True)
    email = db.Column(db.String, nullable=True)
    donvi_id = db.Column(db.Integer,db.ForeignKey('donvi.id'), nullable=True)
    donvi = db.relationship('DonVi', backref=db.backref('cuakhau',lazy='dynamic'),viewonly=True)
    tinhthanh_id = db.Column(db.Integer,db.ForeignKey('tinhthanh.id'), nullable=True)
    tinhthanh = db.relationship('TinhThanh',viewonly=True)
    thutu = db.Column(db.Integer, nullable=True)
    #loaicuakhau
    duongboquocte = db.Column(db.Boolean, default=False)
    duongbochinh = db.Column(db.Boolean, default=False)
    duongbophu = db.Column(db.Boolean, default=False)
    duongsat = db.Column(db.Boolean, default=False)
    duonghangkhong = db.Column(db.Boolean, default=False)
    duongthuyloai1 = db.Column(db.Boolean, default=False)
    duongthuyloai2 = db.Column(db.Boolean, default=False)
    
    quocgia_tiepgiap = db.Column(db.String, nullable=True)
    cuakhau_tiepgiap = db.Column(db.String, nullable=True)
예제 #6
0
class KetQuaNgoaiKiemChatLuongNuocSach(CommonModel):
    __tablename__ = 'ketqua_ngoaikiem_chatluong_nuocsach'
    donvi_id = db.Column(db.Integer, db.ForeignKey('donvi.id'), nullable=False)
    donvi = db.relationship('DonVi', viewonly=True)
    nguoibaocao_id = db.Column(UUID(as_uuid=True), db.ForeignKey('user.id'), nullable=True)
    nguoibaocao = db.relationship('User', viewonly=True)
    tinhtrang = db.Column(db.SmallInteger,nullable=False)
    nambaocao = db.Column(db.Integer, nullable=False)
    ngaybaocao = db.Column(db.DateTime())
    
    donvicapnuoc_id = db.Column(UUID(as_uuid=True), db.ForeignKey('donvicapnuoc.id'), nullable=False)
    donvicapnuoc = db.relationship('DonViCapNuoc', viewonly=True)
    tendonvicapnuoc = db.Column(db.String)
    diachi_donvicapnuoc = db.Column(db.String)
    congsuat_thietke = db.Column(DECIMAL)
    tongso_hogiadinh = db.Column(db.Integer, default=0)
    nguonnuoc_nguyenlieu = db.Column(db.SmallInteger)
    tansuat_noikiem = db.Column(db.String)
    thoigiankiemtra = db.Column(db.DateTime())
    
    tendonvi_ngoaikiem = db.Column(db.String)
    noidung_ngoaikiem = db.Column(db.String)
    thunghiem_chatluong_nuoc = db.Column(db.SmallInteger, default=0)
    loai_donvi_kiemtra = db.Column(db.SmallInteger)
    thanhphan_doankiemtra = db.Column(db.String)
    
    laphoso_theoquydinh = db.Column(db.SmallInteger, default=0)
    hoso_daydu_theoquydinh = db.Column(db.SmallInteger, default=0)
    tailieu_thieu = db.Column(db.String)
    somau_thunghiem_dungquydinh = db.Column(db.SmallInteger, default=0)
    thunghiem_daydu_thongso = db.Column(db.SmallInteger, default=0)
    tansuat_thuchien_noikiem_dungquydinh = db.Column(db.SmallInteger, default=0)
    thuchien_baocao_daydu = db.Column(db.SmallInteger, default=0)
    thuchien_congkhai_thongtin = db.Column(db.SmallInteger, default=0)
    thuchien_bienphap_khacphuc = db.Column(db.SmallInteger, default=0)
    
    tongsomau_noikiem_thunghiem = db.Column(db.Integer, default=0)
    tongsomau_noikiem_dat_quychuan = db.Column(db.Integer, default=0)
    tongsomau_noikiem_khongdat_quychuan = db.Column(db.Integer, default=0)
    
    tong_thongso_noikiem_khongdat = db.Column(db.Integer, default=0)
    danhsachthongso_noikiem_khongdat = db.Column(JSONB)
    
    tong_thongso_ngoaikiem_khongdat = db.Column(db.Integer, default=0)
    danhsachthongso_ngoaikiem_khongdat = db.Column(JSONB)
                                      
    somauvavitri = db.Column(db.Integer, default=0)
    danhsachvitrilaymau = db.Column(JSONB)
    
    ketquangoaikiemchatluongnuoc = db.Column(JSONB)
    ketquangoaikiem = db.Column(db.SmallInteger, default=0)
    nhanxet = db.Column(db.String)
    
    congbo_thongtin_chodonvicapnuoc = db.Column(db.SmallInteger, default=0)
    congkhai_thongtin = db.Column(db.SmallInteger, default=0)
    thongbao_coquan_thamquyen = db.Column(db.SmallInteger, default=0)
    thongbao_donvi_chuquan = db.Column(db.SmallInteger, default=0)
    
    kiennghi = db.Column(db.String)
    ketluan = db.Column(db.String)
예제 #7
0
class StandartTree(db.Model):
    """Эталонная структура дерева для каждого из типов шаблонов, с использованием всех тегов"""
    __bind_key__ = 'caesar'
    __tablename__ = '%s_standart_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_standart_tree.id' % TABLE_PREFIX),
                          index=True)
    template_type_id = db.Column(db.Integer,
                                 db.ForeignKey('%s_template_type.id' %
                                               TABLE_PREFIX),
                                 index=True)
    is_necessary = db.Column(db.Boolean)
    ordernum = db.Column(db.Integer, doc=u'Поле для сортировки тегов')

    tag = db.relationship(Tag)
    parent = db.relationship('StandartTree', remote_side=[id])
    template_type = db.relationship(TemplateType)

    __table_args__ = {'order_by': ordernum}

    def __unicode__(self):
        return self.tag.code
예제 #8
0
class MapVienChuyenNganhNuocVaTinh(CommonModel):
    __tablename__ = 'map_vienchuyennganhnuoc_tinh'
    donvi_id = db.Column(db.Integer, db.ForeignKey('donvi.id'), nullable=False)
    donvi = db.relationship('DonVi', viewonly=True)
    user_id = db.Column(UUID(as_uuid=True), db.ForeignKey('user.id'), nullable=True)
    user = db.relationship('User', viewonly=True)
    danhsachtinhthanh = db.Column(JSONB)
class BaoCaoTienDoDuyTriVSTXBenVung(CommonModel):
    __tablename__ = 'baocao_tiendo_duytri_vstx_benvung'
    donvi_id = db.Column(db.Integer, db.ForeignKey('donvi.id'), nullable=False)
    donvi = db.relationship('DonVi', viewonly=True)
    nguoibaocao_id = db.Column(UUID(as_uuid=True),
                               db.ForeignKey('user.id'),
                               nullable=True)
    nguoibaocao = db.relationship('User', viewonly=True)
    tinhtrang = db.Column(db.SmallInteger, nullable=False)
    ngaybaocao = db.Column(db.DateTime())
    nambaocao = db.Column(db.Integer, nullable=False)
    kybaocao = db.Column(db.SmallInteger, nullable=False)
    loaikybaocao = db.Column(db.Integer, nullable=False)

    tinhthanh_id = db.Column(UUID(as_uuid=True),
                             ForeignKey('tinhthanh.id'),
                             nullable=True)
    tinhthanh = relationship('TinhThanh')
    quanhuyen_id = db.Column(UUID(as_uuid=True),
                             ForeignKey('quanhuyen.id'),
                             nullable=True)
    quanhuyen = relationship('QuanHuyen')
    xaphuong_id = db.Column(UUID(as_uuid=True),
                            ForeignKey('xaphuong.id'),
                            nullable=True)
    xaphuong = relationship('XaPhuong')

    nam_datvesinh_toanxa = db.Column(db.Integer)
    nam_datvesinh_toanxa_benvung = db.Column(db.Integer)
    tyle_truong_duytri_vesinh = db.Column(db.DECIMAL)
    tyle_tramyte_duytri_vesinh = db.Column(db.DECIMAL)
예제 #10
0
class Tasks(CommonModel):
    __tablename__ = 'tasks'
    task_code = db.Column(String(32), index=True, unique=False, nullable=False)
    task_name = db.Column(String(255), nullable=False)
    unsigned_name = db.Column(
        String(255), nullable=True,
        index=True)  # tên không dấu phục vụ truy vấn dữ liệu lớn
    #     sub_task = db.Column(Boolean, default=False) # Nếu là subtask thì bắt buộc phải có parent mới cho lưu vào
    parent_code = db.Column(String(255), nullable=True)
    employees = db.relationship("Employee", secondary="tasks_employees")
    task_info_uid = db.Column(UUID(as_uuid=True), ForeignKey("task_info.id"))
    task_info = db.relationship("TaskInfo")
    tags = db.Column(JSONB())
    priority = db.Column(SmallInteger, index=True,
                         default=2)  # {1: highest, 2: high, 3: low, 4: lowest}
    attach_file = db.Column(String(255))
    link_issue = db.Column(String(255))
    original_estimate = db.Column(Integer)  # minute unit
    start_time = db.Column(BigInteger(), index=True, nullable=False)
    end_time = db.Column(BigInteger(), index=True, nullable=True)
    status = db.Column(SmallInteger, index=True,
                       default=0)  # {0: todo, "2: processing ", "1: done"}
    rating = db.Column(SmallInteger)
    comments = db.Column(JSONB())
    description = db.Column(String(255))
    active = db.Column(SmallInteger, default=1)
    task_many_times = db.Column(Boolean, default=True)
예제 #11
0
class BaoCao(CommonModel):
    __tablename__ = 'baocao'
    id = db.Column(db.Integer, primary_key=True)
    ma = db.Column(db.String(255))
    ngaybaocao = db.Column(db.DateTime(),default=func.now())
    loaikybaocao = db.Column(db.Integer, nullable=False)
    loaibaocao = db.Column(db.SmallInteger()) #1 - don vi, 2 cua khau
    kybaocao = db.Column(db.SmallInteger, nullable=False)
    nambaocao = db.Column(db.Integer, nullable=False)
    tungay = db.Column(db.Date())
    denngay = db.Column(db.Date())
    donvi_id = db.Column(db.Integer,db.ForeignKey('donvi.id'), nullable=True)
    donvi = db.relationship('DonVi',viewonly=True)
    cuakhau_id = db.Column(db.Integer,db.ForeignKey('cuakhau.id'), nullable=True)
    cuakhau = db.relationship('CuaKhau',viewonly=True)
    nhanxetnguoi = db.Column(db.String())
    nhanxetphuongtien = db.Column(db.String())
    nhanxethanghoa = db.Column(db.String())
    nhanxetthithe = db.Column(db.String())
    nhanxetvssh = db.Column(db.String())
    
    nhanxet = db.Column(db.String())
    kiennghi = db.Column(db.String())
    hoatdongkhac = db.Column(db.String())
    nhanlucts = db.Column(db.Integer())
    nhanlucbienche = db.Column(db.Integer())
    nhanluchopdong = db.Column(db.Integer())
    tinhtrang = db.Column(db.SmallInteger, nullable=False, default=1)
예제 #12
0
class BaoCaoVienChuyenNganhNuoc(CommonModel):
    __tablename__ = 'baocao_vienchuyennganh_nuoc'
    donvi_id = db.Column(db.Integer, db.ForeignKey('donvi.id'), nullable=False)
    donvi = db.relationship('DonVi', viewonly=True)
    nguoibaocao_id = db.Column(UUID(as_uuid=True), db.ForeignKey('user.id'), nullable=True)
    nguoibaocao = db.relationship('User', viewonly=True)
    tinhtrang = db.Column(db.SmallInteger,nullable=False)
    ngaybaocao = db.Column(db.DateTime())
    nambaocao = db.Column(db.Integer, nullable=False)
    kybaocao = db.Column(db.SmallInteger, nullable=False, default=1)
    loaikybaocao = db.Column(db.Integer, nullable=False)#thang=1,quy=2,6thang=3,nam=4
    
    tong_tinh_phutrach = db.Column(db.Integer, default=0)
    tong_tinh_cobaocao = db.Column(db.Integer, default=0)
    tong_donvi_capnuoc_phutrach = db.Column(db.Integer, default=0)
    tong_hogiadinh_duoccungcapnuoc = db.Column(db.Integer, default=0)
    tong_hogiadinh_diaban = db.Column(db.Integer, default=0)
    
    tong_maunuoc_thunghiem_ngoaikiem_vien = db.Column(db.Integer, default=0)
    tong_mau_dat_quychuan_ngoaikiem_vien = db.Column(db.Integer, default=0)
    tong_mau_khongdat_quychuan_ngoaikiem_vien = db.Column(db.Integer, default=0)
    thongso_khongdat_ngoaikiem_vien = db.Column(JSONB)

    ketqua_kiemtra_noikiem_tinh = db.Column(JSONB)
    
    cacdexuat_kythuat = db.Column(db.String)
    nghiencuu_chatluong_nuocsach = db.Column(db.String)
    ketluan = db.Column(db.String)
    dexuat = db.Column(db.String)
class DuyetVeSinhToanXa(CommonModel):
    __tablename__ = 'duyet_vesinh_toanxa'
    donvi_id = db.Column(db.Integer, db.ForeignKey('donvi.id'), nullable=False)
    donvi = db.relationship('DonVi', viewonly=True)
    nguoibaocao_id = db.Column(UUID(as_uuid=True),
                               db.ForeignKey('user.id'),
                               nullable=True)
    nguoibaocao = db.relationship('User', viewonly=True)
    tinhtrang = db.Column(db.SmallInteger, nullable=False)

    tinhthanh_id = db.Column(UUID(as_uuid=True),
                             ForeignKey('tinhthanh.id'),
                             nullable=True)
    tinhthanh = relationship('TinhThanh')
    quanhuyen_id = db.Column(UUID(as_uuid=True),
                             ForeignKey('quanhuyen.id'),
                             nullable=True)
    quanhuyen = relationship('QuanHuyen')
    xaphuong_id = db.Column(UUID(as_uuid=True),
                            ForeignKey('xaphuong.id'),
                            nullable=True)
    xaphuong = relationship('XaPhuong')

    nam_datvesinh_toanxa = db.Column(db.Integer)
    nam_datvesinh_toanxa_benvung = db.Column(db.Integer)
예제 #14
0
class UserDonvi(CommonModel):
    __tablename__ = 'user_donvi'
    id = db.Column(UUID(as_uuid=True), primary_key=True, default=default_uuid)
    fullname = db.Column(db.String(255))
    email = db.Column(db.String(255))
    password = db.Column(db.String(255))
    cfpassword = db.Column(db.String(255))
    phone = db.Column(db.String(255))
    macongdan = db.Column(String(200))
    user_id = db.Column(UUID(as_uuid=True),
                        db.ForeignKey('user.id',
                                      onupdate="CASCADE",
                                      ondelete="SET NULL"),
                        nullable=True)
    users = db.relationship('User', viewonly=True)
    donvi_id = db.Column(db.Integer,
                         db.ForeignKey('donvi.id',
                                       onupdate="CASCADE",
                                       ondelete="SET NULL"),
                         nullable=True)
    donvi = db.relationship('DonVi', foreign_keys=[donvi_id], viewonly=True)
    donvi_sodienthoai = db.Column(db.String())
    donvi_diachi = db.Column(db.String())
    donvi_ten = db.Column(db.String())
    donvi_tuyendonvi_id = db.Column(db.Integer,
                                    db.ForeignKey('tuyendonvi.id',
                                                  onupdate="SET NULL"),
                                    nullable=True)
    donvi_tuyendonvi = db.relationship('TuyenDonVi')
    xaphuong_id = db.Column(UUID(as_uuid=True),
                            ForeignKey('xaphuong.id'),
                            nullable=True)
    xaphuong = relationship('XaPhuong')
    quanhuyen_id = db.Column(UUID(as_uuid=True),
                             ForeignKey('quanhuyen.id'),
                             nullable=True)
    quanhuyen = relationship('QuanHuyen')
    tinhthanh_id = db.Column(UUID(as_uuid=True),
                             ForeignKey('tinhthanh.id'),
                             nullable=True)
    tinhthanh = relationship('TinhThanh', viewonly=True)
    quocgia_id = db.Column(UUID(as_uuid=True),
                           ForeignKey('quocgia.id'),
                           nullable=True)
    quocgia = relationship('QuocGia')
    captren_id = db.Column(db.Integer,
                           db.ForeignKey('donvi.id',
                                         onupdate="CASCADE",
                                         ondelete="SET NULL"),
                           nullable=True)
    captren = db.relationship('DonVi',
                              foreign_keys=[captren_id],
                              backref=db.backref('user_donvi', lazy='dynamic'),
                              viewonly=True)
    trangthai = db.Column(db.SmallInteger, default=2)
예제 #15
0
class ScheduleTicket(db.Model):
    __tablename__ = 'ScheduleTicket'

    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    schedule_id = db.Column(db.Integer,
                            db.ForeignKey('Schedule.id'),
                            nullable=False)
    begTime = db.Column(db.Time)
    endTime = db.Column(db.Time)
    attendanceType_id = db.Column(db.Integer,
                                  db.ForeignKey('rbAttendanceType.id'),
                                  nullable=False)
    createDatetime = db.Column(db.DateTime, nullable=False)
    createPerson_id = db.Column(db.Integer,
                                db.ForeignKey('Person.id'),
                                index=True)
    modifyDatetime = db.Column(db.DateTime, nullable=False)
    modifyPerson_id = db.Column(db.Integer,
                                db.ForeignKey('Person.id'),
                                index=True)
    deleted = db.Column(db.SmallInteger, nullable=False, server_default='0')

    attendanceType = db.relationship('rbAttendanceType', lazy=False)
    client_ticket = db.relationship(
        'ScheduleClientTicket',
        lazy=False,
        primaryjoin=
        "and_(ScheduleClientTicket.ticket_id == ScheduleTicket.id, ScheduleClientTicket.deleted == 0)",
        uselist=False)

    schedule = db.relationship(
        'Schedule',
        lazy="joined",
        innerjoin=True,
        uselist=False,
        primaryjoin='and_('
        'Schedule.deleted == 0, ScheduleTicket.deleted == 0, ScheduleTicket.schedule_id == Schedule.id)'
    )

    @property
    def client(self):
        ct = self.client_ticket
        return ct.client if ct else None

    @property
    def begDateTime(self):
        return datetime.datetime.combine(
            self.schedule.date,
            self.begTime) if self.begTime is not None else None

    @property
    def endDateTime(self):
        return datetime.datetime.combine(
            self.schedule.date,
            self.endTime) if self.endTime is not None else None
예제 #16
0
class Subjects(CommonModel):
    __tablename__ = 'subjects'
    id_subjects = db.Column(String(30))
    subjects_name = db.Column(String(100), nullable=False)
    secturers = db.Column(String(50), nullable=False)
    student_total = db.Column(Integer())
    Schedules = db.relationship("Schedule",
                                order_by="Schedule.id",
                                cascade="all, delete-orphan")
    Student_id = db.Column(UUID(as_uuid=True), db.ForeignKey("student.id"))
    Students = db.relationship("Student")
class TienDoKeHoachBCC(CommonModel):
    __tablename__ = 'tiendo_kehoach_bcc'
    donvi_id = db.Column(db.Integer, db.ForeignKey('donvi.id'), nullable=False)
    donvi = db.relationship('DonVi', viewonly=True)
    nguoibaocao_id = db.Column(UUID(as_uuid=True),
                               db.ForeignKey('user.id'),
                               nullable=True)
    nguoibaocao = db.relationship('User', viewonly=True)
    tinhtrang = db.Column(db.SmallInteger, nullable=False)
    ngaybaocao = db.Column(db.DateTime(), default=default_datetime_now)
    nambaocao = db.Column(db.Integer, nullable=False)
    kybaocao = db.Column(db.SmallInteger, nullable=False)
    loaikybaocao = db.Column(db.Integer, nullable=False)

    #     danhmucnganh_id = db.Column(UUID(as_uuid=True), ForeignKey('danhmucnganh.id'), nullable=True)
    #     danhmucnganh = relationship('DanhMucNganh')
    tinhthanh_id = db.Column(UUID(as_uuid=True),
                             ForeignKey('tinhthanh.id'),
                             nullable=True)
    tinhthanh = relationship('TinhThanh')
    quanhuyen_id = db.Column(UUID(as_uuid=True),
                             ForeignKey('quanhuyen.id'),
                             nullable=True)
    quanhuyen = relationship('QuanHuyen')
    xaphuong_id = db.Column(UUID(as_uuid=True),
                            ForeignKey('xaphuong.id'),
                            nullable=True)
    xaphuong = relationship('XaPhuong')
    thonxom_id = db.Column(UUID(as_uuid=True),
                           ForeignKey('thonxom.id'),
                           nullable=True)
    thonxom = relationship('ThonXom')

    tiendo_xaydung = db.Column(db.SmallInteger, nullable=True)
    tiendo_rasoat = db.Column(db.SmallInteger, nullable=True)
    tiendo_pheduyet = db.Column(db.SmallInteger, nullable=True)
    ngay_pheduyet = db.Column(db.DateTime())
    sohoatdong_cotloi_pheduyet = db.Column(db.Integer)
    sohoatdong_cotloi_hoanthanh = db.Column(db.Integer)
    #     nganh_id = db.Column(UUID(as_uuid=True), ForeignKey('nganh.id'), nullable=True)
    #     nganh = relationship('Nganh')

    giangvien = db.Column(db.Integer, default=0)  # giang vien tai don vi
    giangvien_nu = db.Column(db.Integer, default=0)  # giang vien tai don vi
    tongsogiangvien = db.Column(
        db.Integer, default=0)  #tong so giang vien, bao gom cac don vi con
    tongsogiangvien_nu = db.Column(db.Integer, default=0)
    tongsonguoithamgia = db.Column(db.Integer, default=0)
    tongsonguoithamgia_nu = db.Column(db.Integer, default=0)
    tongsonguoithamgia_dtts = db.Column(db.Integer, default=0)

    danhsach_hoatdong = db.Column(JSONB())
    tuyendonvi = db.Column(db.String)  #tinh/huyen/xa/thon
예제 #18
0
class User(CommonModel):
    __tablename__ = 'user'
    display_name = db.Column(String(255), nullable=False)
    phone = db.Column(String(50), index=True, nullable=False)
    email = db.Column(String(100), index=True, nullable=True)
    birthday = db.Column(String())
    phone_other = db.Column(String(50), nullable=True)
    email_other = db.Column(String(100), nullable=True)
    gender = db.Column(db.String(20))
    avatar = db.Column(Text())

    password = db.Column(String(255), nullable=True)
    salt = db.Column(String(255), nullable=True)
    role_id = db.Column(
        UUID(as_uuid=True),
        ForeignKey("role.id", onupdate="SET NULL", ondelete="SET NULL"))
    role = db.relationship('Role')

    department = db.Column(String(50), nullable=True)
    signature = db.Column(Text(), nullable=True)
    address_street = db.Column(String(150), nullable=True)
    address_city = db.Column(String(100), nullable=True)
    address_state = db.Column(String(100), nullable=True)
    address_country = db.Column(String(25), nullable=True)
    address_postalcode = db.Column(String(10), nullable=True)
    tz = db.Column(String(30), nullable=True)
    theme = db.Column(String(100), nullable=True)
    language = db.Column(String(36), nullable=True)
    time_zone = db.Column(String(200), nullable=True)
    config_data = db.Column(JSONB(), default=default_user_config)
    tenant_id = db.Column(String(),
                          ForeignKey("tenant.id",
                                     onupdate="RESTRICT",
                                     ondelete="RESTRICT"),
                          nullable=False)
    tenant = db.relationship('Tenant')

    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.role_name for role in self.roles)
        else:
            return role in self.roles

    def add_role(self, role):
        pass

    def remove_role(self, role):
        pass
예제 #19
0
class Group(CommonModel):
    __tablename__ = 'group'
    group_name = db.Column(String)
    unsigned_name = db.Column(String)
    description = db.Column(String)
    parent_id = db.Column(UUID(as_uuid=True),
                          ForeignKey("group.id"),
                          default=None)
    assignee_id = db.Column(UUID(as_uuid=True), ForeignKey("user.id"))
    assignee = db.relationship("User", foreign_keys=[assignee_id])
    members = db.relationship("User", secondary="groups_users")
    checklists = db.relationship("Checklist", secondary="checklists_groups")
    tasks_info = db.relationship('TaskInfo')
예제 #20
0
class TaskschedulesTaskinfo(CommonModel):
    __tablename__ = 'taskscheduledetail_taskinfo'
    task_uid = db.Column(UUID(as_uuid=True),
                         ForeignKey('task_info.id',
                                    onupdate='cascade',
                                    ondelete='cascade'),
                         primary_key=True)
    task = db.relationship("TaskInfo")
    task_schedule_uid = db.Column(UUID(as_uuid=True),
                                  ForeignKey('task_scheduledetail.id',
                                             onupdate='cascade',
                                             ondelete='cascade'),
                                  primary_key=True)
    task_schedule = db.relationship("TaskScheduleDetail")
예제 #21
0
class TasksEmployees(CommonModel):
    __tablename__ = 'tasks_employees'
    task_uid = db.Column(UUID(as_uuid=True),
                         ForeignKey('tasks.id',
                                    onupdate='cascade',
                                    ondelete='cascade'),
                         primary_key=True)
    task = db.relationship("Tasks")
    employee_uid = db.Column(UUID(as_uuid=True),
                             ForeignKey('employee.id',
                                        onupdate='cascade',
                                        ondelete='cascade'),
                             primary_key=True)
    employee = db.relationship("Employee")
예제 #22
0
class TaskGroupEmployee(CommonModel):
    __tablename__ = 'taskgroup_employee'
    task_group_uid = db.Column(UUID(as_uuid=True),
                               ForeignKey('task_group.id',
                                          onupdate='cascade',
                                          ondelete='cascade'),
                               primary_key=True)
    task_group = db.relationship("TaskGroup")
    employee_uid = db.Column(UUID(as_uuid=True),
                             ForeignKey('employee.id',
                                        onupdate='cascade',
                                        ondelete='cascade'),
                             primary_key=True)
    employee = db.relationship("Employee")
    role = db
예제 #23
0
class ContactRoomSession(CommonModel):
    __tablename__ = 'contact_room_session'
    start_time = db.Column(BigInteger)
    end_time = db.Column(BigInteger)
    do_not_distrub = db.Column(Boolean(), default=False)
    extra_data = db.Column(JSONB())
    people_number = db.Column(Integer())
    children_number = db.Column(Integer(), default = 0)
    note = db.Column(Text())
    checkout = db.Column(Boolean(), default=False)
    contacts = db.relationship("Contact")
    rooms = db.relationship("Room")
    contact_id = db.Column(UUID(as_uuid=True), ForeignKey("contact.id", onupdate="CASCADE", ondelete="RESTRICT"))
    room_id = db.Column(UUID(as_uuid=True), ForeignKey("room.id", onupdate="CASCADE", ondelete="RESTRICT"))
    tenant_id = db.Column(String(), ForeignKey("tenant.id", onupdate="CASCADE", ondelete="RESTRICT"), nullable=False)
예제 #24
0
class Comment(db.Model):
    __tablename__ = "comments"

    id = db.Column(db.Integer, primary_key=True)
    content = db.Column(db.Text(length=600))
    author_id = db.Column(db.Integer, db.ForeignKey("users.id"))
    author = db.relationship("User")
    game_id = db.Column(db.Integer, db.ForeignKey("games.id"))
    game = db.relationship("Game")
    replies = db.relationship(
        "Comment",
        secondary=comment_reply,
        primaryjoin=("Comment.id==comment_reply.c.reply_id"),
        secondaryjoin=("Comment.id==comment_reply.c.comment_id"),
    )
예제 #25
0
class Checklist(CommonModel):
    __tablename__ = "checklist"
    checklist_name = db.Column(String(255), nullable=False)
    unsigned_name = db.Column(String(255), nullable=False)
    note = db.Column(String(255))
    shifts = db.relationship("Shift", secondary="checklists_shifts")
    tasks_info = db.relationship("TaskInfo")
    # group_id = db.Column(UUID(as_uuid=True), ForeignKey('group.id',onupdate='cascade',ondelete='cascade'))
    groups = db.relationship("Group", secondary="checklists_groups")
    time_worker = db.Column(SmallInteger, default=0000)  #default 0h:0m
    cycle_worker = db.Column(String(20), default="week")  #week or month
    days_worker_month = db.Column(JSONB(), default=[])  #25,26,27... in month
    days_worker_week = db.Column(
        JSONB(), default=[0, 1, 2, 3, 4, 5,
                          6])  #0,1,2...,6  <=> sunday, monday...saturday
예제 #26
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
예제 #27
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')
예제 #28
0
class Genre(db.Model):
    __tablename__ = "genres"

    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String(120), unique=True)
    parent_id = db.Column(db.Integer, db.ForeignKey("genres.id"))
    parent_genre = db.relationship("Genre", remote_side=[id])
예제 #29
0
class Country(CommonModel):
    __tablename__ = "country"
    country_name = db.Column(db.String(50))
    code = db.Column(db.String(50))
    cities = db.relationship("City",
                             order_by="City.id",
                             cascade="all, delete-orphan")
예제 #30
0
class User(CommonModel):
    __tablename__ = 'user'
    # Authentication Attributes.
    display_name = db.Column(String(255), nullable=False)
    unsigned_display_name = db.Column(String(255))
    email = db.Column(String(255), index=True)
    phone = db.Column(String(255), index=True, unique=True, nullable=False)
    password = db.Column(String(255), nullable=False)
    salt = db.Column(String(255), nullable=False)
    is_active = db.Column(Boolean, default=True)
    id_identifier = db.Column(String(32), index=True)
    gender = db.Column(SmallInteger(), default=1)
    birthday = db.Column(BigInteger())
    address = db.Column(String)
    status = db.Column(String)
    start_time = db.Column(BigInteger(), index=True)
    end_time = db.Column(BigInteger(), index=True)
    group_last_access_id = db.Column(UUID(as_uuid=True),
                                     ForeignKey("group.id"))
    group_last_access = db.relationship("Group",
                                        foreign_keys=[group_last_access_id])

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