class User(db.Model): __tablename__ = 'user__user' id = col(db.Integer, primary_key=True) email = col(db.String(100), unique=True) password = col(db.Text) roles = col(db.Text) is_active = col(db.Boolean, default=True) db.UniqueConstraint(email) @property def rolenames(self): try: return self.roles.split(',') except Exception: return [] @classmethod def lookup(cls, email): return cls.query.filter_by(email=email).one_or_none() @classmethod def identify(cls, id): return cls.query.get(id) @property def identity(self): return self.id def is_valid(self): return self.is_active
class ChristianName(Model): __tablename__ = 'hoso__christian_name' id = col(db.String(24), primary_key=True) sex = col(db.String(6), nullable=False) tieng_viet = col(db.String(250)) tieng_anh = col(db.String(250)) code = col(db.String(250), unique=True) profiles = db.relation('Profile', backref='christianname', lazy=True)
class Affect: affected_group_id: int = col("AffectActionListGroupDefID", nullable=True) affected_action_id: int = col("AffectActionDefID", nullable=True) affected_task: Task = col("AffectActionTypeID", nullable=True) offset: float = col("AffectOffset", nullable=True) auto_complete: bool = col("AffectAutoComplete", nullable=True) created_action_group_id: int = col("CreateActionActionListGroupDefID", nullable=True) created_action_action_id: int = col("CreateActionActionDefID", nullable=True) created_group_id: int = col("CreateGroupActionListGroupDefID", nullable=True)
class PartnerTypes: id: int = col("PartnerCompanyID") type_id: int = col("PartnerTypeID")
class Partner: id: int = col("PartnerCompanyID") name: str = col("Name")
class EmailPartnerTypeRecipient: """The partner type that should receive the email""" email_id: int = col("ActionEmailTemplateID") partner_type_id: int = col("PartnerTypeID")
class Email: id: int = col("ActionEmailTemplateID") name: str = col("ActionEmailTemplateName") subject: str = col("EmailSubject", nullable=True) body: str = col("EmailBody", nullable=True) # 0 - neither attach by template or document type # 1 - attach by template only # 2 - attach by document type # 3 - attach by both template and document type email_attachment_type: int = col("EmailAttachmentType") generate_hud: bool = col("GenerateHUD") generate_buyer_statement: bool = col("GenerateBuyerStatement") combine_as_pdf: bool = col("CombineAsPDF") pdf_name: str = col("PDFName", nullable=True) pdf_document_type_id: int = col("PDFDocumentTypeID", nullable=True) # 1 = user, 2 = internet orders, 3 = team, 4 = team group, 5 = user's reply to, 6 = issue tracker, 7 = assigned team reply_to_type: int = col("ReplyToType") transmit_via_xml: bool = col("TransmitViaXML") combine_generated_documents_attach_to_email: bool = col( "CombineGeneratedDocumentsAttachToEmail")
class ActionEvent: id: int = col("ActionEventDefID") name: str = col("Name")
class GroupAction: group_id: int = col("ActionListGroupDefID") action_id: int = col("ActionDefID") dynamic: bool = col("Dynamic")
class Action: id: int = col("ActionDefID") name: str = col("Name") display_name: str = col("DisplayName") description: str = col("Description", nullable=True) hidden: bool = col("Hidden")
class Trigger(Affect): external_action_id: int = col("ExternalActionDefID") group_id: int = col("ActionListGroupDefID") action_event_id: int = col("ActionEventDefID", nullable=True) document_type_id: int = col("DocumentTypeID", nullable=True)
class ActionEmail: action_id: int = col("ActionDefID") email_id: int = col("ActionEmailTemplateID") task: Task = col("ActionStartComplete", parser=_email_start_complete_to_task)
class Template: id: int = col("TemplateID") name: str = col("Name") filename: str = col("Filename") document_type_id: int = col("DocumentTypeID")
class EmailTemplate: email_id: int = col("ActionEmailTemplateID") template_id: int = col("TemplateID")
class EmailPartnerRestriction: partner_id: int = col("PartnerCompanyID", nullable=True) email_id: int = col("ActionEmailTemplateID") include: bool = col("IncludeExclude")
class PartnerAutoAdds: id: int = col("PartnerCompanyID") type_id: int = col("PartnerTypeId") auto_add_id: int = col("AutoAddPartnerCompanyID") auto_add_type_id: int = col("AutoAddPartnerTypeID")
class PartnerType: id: int = col("PartnerTypeID") name: str = col("Name")
class GroupPartnerRestriction: group_id: int = col("ActionListGroupDefID") partner_id: int = col("PartnerCompanyID") include: bool = col("ActionPartnerAddTypeID", parser=_group_partner_include)
class ExternalAction: id: int = col("ExternalActionDefID") name: str = col("Name")
class Group: id: int = col("ActionListGroupDefID") name: str = col("ActionListGroupName")
class DocumentType: id: int = col("DocumentTypeID") name: str = col("Name")
class GroupActionAffect(Affect): task: Task = col("ActionTypeID", nullable=True) group_id: int = col("ActionListGroupDefID") action_id: int = col("ActionDefID")
class Profile(Model): __tablename__ = 'hoso__thanh_vien' id = col(db.Integer, primary_key=True, autoincrement=True) id_user = ref('user__user', nullable=True) user = rel('User', backref='profile') sex = col(db.String(6), nullable=False) dob = col(db.Date) enabled = col(db.Boolean, default=True) so_dien_thoai = col(db.String(15)) so_dien_thoai_me = col(db.String(15)) so_dien_thoai_bo = col(db.String(15)) so_dien_thoai_nha = col(db.String(15)) dia_chi_tam_tru = col(db.String(255)) dia_chi_thuong_tru = col(db.String(255)) firstname = col(db.String(50), nullable=False) middlename = col(db.String(50), nullable=False) lastname = col(db.String(50), nullable=False) id_ten_thanh = db.Column( db.String(24), db.ForeignKey('hoso__christian_name.id'), nullable=False, ) ho_ten_bo = col(db.String(255)) ho_ten_me = col(db.String(255)) nghe_nghiep_bo = col(db.String(255)) nghe_nghiep_me = col(db.String(255)) # id_ten_thanh_bo = ref('hoso__christian_name') # id_ten_thanh_me = ref('hoso__christian_name') notes = col(db.Text) created_at = col(db.DateTime, nullable=False, default=dt.datetime.utcnow) updated_at = col(db.DateTime, nullable=False, default=dt.datetime.utcnow) # def __init__(self): def __repr__(self) -> str: return super().__repr__() def create(self): db.session.add(self) db.session.commit() return self
class ActionList: id: int = col("ActionListDefID") name: str = col("Name")
class ActionListGroups: id: int = col("ActionListDefId") group_id: int = col("ActionListGroupDefId") order: int = col("GroupOrder") optional: bool = col("Optional")
class EmailDocument: email_id: int = col("ActionEmailTemplateID") document_type_id: int = col("DocumentTypeID")