Ejemplo n.º 1
0
class Qualification(Base):
    __tablename__ = 'qualification'

    qualification_id = Column(INTEGER(11), primary_key=True)
    id_qualification_type = Column(ForeignKey('qualification_type.qualification_type_id'), index=True)
    id_course = Column(ForeignKey('course.course_id'), index=True)
    id_usr_student = Column(ForeignKey('user.user_id'), index=True)
    id_subject = Column(ForeignKey('subject.subject_id'), index=True)
    value = Column(INTEGER(11))

    course = relationship('Course')
    qualification_type = relationship('QualificationType')
    subject = relationship('Subject')
    user = relationship('User')
Ejemplo n.º 2
0
class Customer(DeclarativeBaseGuid):
    __tablename__ = 'customers'

    __table_args__ = {}

    # column definitions
    name = Column('name', VARCHAR(length=2048), nullable=False)
    id = Column('id', VARCHAR(length=2048), nullable=False)
    notes = Column('notes', VARCHAR(length=2048), nullable=False)
    active = Column('active', INTEGER(), nullable=False)
    _discount_num = Column('discount_num', BIGINT())
    _discount_denom = Column('discount_denom', BIGINT())
    discount = hybrid_property_gncnumeric(_discount_num, _discount_denom)
    _credit_num = Column('credit_num', BIGINT(), nullable=False)
    _credit_denom = Column('credit_denom', BIGINT(), nullable=False)
    credit = hybrid_property_gncnumeric(_credit_num, _credit_denom)
    currency_guid = Column('currency', VARCHAR(length=32), ForeignKey('commodities.guid'),nullable=False)
    tax_override = Column('tax_override', INTEGER(), nullable=False)

    addr_name = Column('addr_name', VARCHAR(length=1024))
    addr_addr1 = Column('addr_addr1', VARCHAR(length=1024))
    addr_addr2 = Column('addr_addr2', VARCHAR(length=1024))
    addr_addr3 = Column('addr_addr3', VARCHAR(length=1024))
    addr_addr4 = Column('addr_addr4', VARCHAR(length=1024))
    addr_phone = Column('addr_phone', VARCHAR(length=128))
    addr_fax = Column('addr_fax', VARCHAR(length=128))
    addr_email = Column('addr_email', VARCHAR(length=256))
    addr = composite(Address, addr_addr1, addr_addr2, addr_addr3, addr_addr4,
                     addr_email, addr_fax, addr_name, addr_phone)

    shipaddr_name = Column('shipaddr_name', VARCHAR(length=1024))
    shipaddr_addr1 = Column('shipaddr_addr1', VARCHAR(length=1024))
    shipaddr_addr2 = Column('shipaddr_addr2', VARCHAR(length=1024))
    shipaddr_addr3 = Column('shipaddr_addr3', VARCHAR(length=1024))
    shipaddr_addr4 = Column('shipaddr_addr4', VARCHAR(length=1024))
    shipaddr_phone = Column('shipaddr_phone', VARCHAR(length=128))
    shipaddr_fax = Column('shipaddr_fax', VARCHAR(length=128))
    shipaddr_email = Column('shipaddr_email', VARCHAR(length=256))
    shipaddr = composite(Address, shipaddr_addr1, shipaddr_addr2, shipaddr_addr3, shipaddr_addr4,
                         shipaddr_email, shipaddr_fax, shipaddr_name, shipaddr_phone)

    term_guid = Column('terms', VARCHAR(length=32), ForeignKey('billterms.guid'))
    tax_included = Column('tax_included', INTEGER())
    taxtable_guid = Column('taxtable', VARCHAR(length=32), ForeignKey('taxtables.guid'))

    # relation definitions
    taxtable = relation('Taxtable')
    currency= relation('Commodity')
    term = relation('Billterm')
Ejemplo n.º 3
0
class TestCase(Base):
    """
    This class is mapped to the test_case table in the Management schema.
    DB Comment: Can be an internal TAF test case or more likely a representation of a TFS test case.
    """
    __tablename__ = 'test_case'
    __table_args__ = {'schema': schema_name}

    tc_id_seq = Sequence('test_case_id_seq', metadata=Base.metadata)
    tc_id = Column(INTEGER(),
                   Sequence('test_case_id_seq'),
                   primary_key=True,
                   nullable=False,
                   server_default=DefaultClause(tc_id_seq.next_value(),
                                                for_update=False))
    tc_title = Column(VARCHAR(length=500))
    """A short description of the test case."""
    tc_description = Column(TEXT())
    """The details of the test case, or even the test steps, if it is short or simple."""
    ext_id = Column(INTEGER())
    """A link to TFS if the TC represents a TFS entity."""
    tc_version = Column(REAL(),
                        primary_key=True,
                        nullable=False,
                        server_default=DefaultClause('0.1', for_update=False))
    """The test case version. Each modification has to trigger a new version and a backup."""
    created_by = Column(VARCHAR(length=200), nullable=False)
    created_time = Column(TIMESTAMP(), nullable=False)
    last_modified_by = Column(VARCHAR(length=200))
    last_modified_time = Column(TIMESTAMP())
    # The database also has a CHECK constraint on this field for the allowed values: MANUAL, AUTO, BDD, DDT, KWD, COMBI
    # Here the CHECK constraint is passed as a string as SQLAlchemy doesn't know how to handle these, so this is
    # exactly as it appears in the PostgreSQL database
    # https://docs.sqlalchemy.org/en/13/core/constraints.html?highlight=constraint#check-constraint
    test_type = Column(VARCHAR(length=20),
                       CheckConstraint(
                           "((test_type)::text = "
                           "ANY ((ARRAY['MANUAL'::character varying, "
                           "'AUTO'::character varying, "
                           "'BDD'::character varying, "
                           "'DDT'::character varying, "
                           "'KWD'::character varying])::text[]))"),
                       nullable=False,
                       server_default=DefaultClause('AUTO', for_update=False))
    """MANUAL, AUTO, BDD, DDT, KWD, COMBI"""
    linked_test_id = Column(INTEGER())
    """The DB ID of a BDD feature or scenario, a KWD set a combinatorial set, or a TFS ID."""
    linked_test_format = Column(VARCHAR(length=20))
    """File, database, TFS."""
Ejemplo n.º 4
0
class Order(DeclarativeBaseGuid):
    __tablename__ = 'orders'

    __table_args__ = {}

    # column definitions
    id = Column('id', VARCHAR(length=2048), nullable=False)
    notes = Column('notes', VARCHAR(length=2048), nullable=False)
    reference = Column('reference', VARCHAR(length=2048), nullable=False)
    active = Column('active', INTEGER(), nullable=False)

    date_opened = Column('date_opened', _DateTime(), nullable=False)
    date_closed = Column('date_closed', _DateTime(), nullable=False)
    owner_type = Column('owner_type', INTEGER(), nullable=False)
    owner_guid = Column('owner_guid', VARCHAR(length=32), nullable=False)
Ejemplo n.º 5
0
class Sell(Base):
    __tablename__ = 'sell'

    sell_no = Column(INTEGER(11), primary_key=True)
    stock_id = Column(CHAR(10))
    stock_name = Column(ForeignKey('message.stock_name'), index=True)
    stock_price = Column(DECIMAL(7, 2))
    stock_num = Column(INTEGER(11))
    time = Column(TIMESTAMP, server_default=text("CURRENT_TIMESTAMP"))
    state = Column(Enum('1', '2', '3'))
    price = Column(DECIMAL(7, 2))
    complete_num = Column(INTEGER(11))
    user_id = Column(INTEGER(11))

    message = relationship('Message')
Ejemplo n.º 6
0
class Tran(Base):
    __tablename__ = 'tran'

    trans_no = Column(INTEGER(11), primary_key=True)
    stock_id = Column(CHAR(10))
    stock_name = Column(ForeignKey('message.stock_name'), index=True)
    trans_price = Column(DECIMAL(7, 2))
    trans_stock_num = Column(INTEGER(11))
    time = Column(TIMESTAMP, server_default=text("CURRENT_TIMESTAMP"))
    sell_no = Column(ForeignKey('sell.sell_no'), index=True)
    buy_no = Column(ForeignKey('buy.buy_no'), index=True)

    buy = relationship('Buy')
    sell = relationship('Sell')
    message = relationship('Message')
Ejemplo n.º 7
0
class Node(DeclarativeBase):
    """node model"""
    __tablename__ = 'nodes'
    #column definitions
    address = Column(u'address', VARCHAR(length=128), nullable=False)
    enabled = Column(u'enabled', INTEGER(), nullable=False)
    id = Column(u'id', BIGINT(), primary_key=True, nullable=False)
    lbid = Column(u'lbid',
                  BIGINT(),
                  ForeignKey('loadbalancers.id'),
                  nullable=False)
    port = Column(u'port', INTEGER(), nullable=False)
    status = Column(u'status', VARCHAR(length=128), nullable=False)
    weight = Column(u'weight', INTEGER(), nullable=False)
    backup = Column(u'backup', INTEGER(), nullable=False, default=0)
Ejemplo n.º 8
0
class User(SAFRSBase, Base):
    __tablename__ = 'user'

    Host = Column(CHAR(60, 'utf8_bin'), primary_key=True, nullable=False, server_default=text("''"))
    User = Column(CHAR(32, 'utf8_bin'), primary_key=True, nullable=False, server_default=text("''"))
    Select_priv = Column(ENUM('N', 'Y'), nullable=False, server_default=text("'N'"))
    Insert_priv = Column(ENUM('N', 'Y'), nullable=False, server_default=text("'N'"))
    Update_priv = Column(ENUM('N', 'Y'), nullable=False, server_default=text("'N'"))
    Delete_priv = Column(ENUM('N', 'Y'), nullable=False, server_default=text("'N'"))
    Create_priv = Column(ENUM('N', 'Y'), nullable=False, server_default=text("'N'"))
    Drop_priv = Column(ENUM('N', 'Y'), nullable=False, server_default=text("'N'"))
    Reload_priv = Column(ENUM('N', 'Y'), nullable=False, server_default=text("'N'"))
    Shutdown_priv = Column(ENUM('N', 'Y'), nullable=False, server_default=text("'N'"))
    Process_priv = Column(ENUM('N', 'Y'), nullable=False, server_default=text("'N'"))
    File_priv = Column(ENUM('N', 'Y'), nullable=False, server_default=text("'N'"))
    Grant_priv = Column(ENUM('N', 'Y'), nullable=False, server_default=text("'N'"))
    References_priv = Column(ENUM('N', 'Y'), nullable=False, server_default=text("'N'"))
    Index_priv = Column(ENUM('N', 'Y'), nullable=False, server_default=text("'N'"))
    Alter_priv = Column(ENUM('N', 'Y'), nullable=False, server_default=text("'N'"))
    Show_db_priv = Column(ENUM('N', 'Y'), nullable=False, server_default=text("'N'"))
    Super_priv = Column(ENUM('N', 'Y'), nullable=False, server_default=text("'N'"))
    Create_tmp_table_priv = Column(ENUM('N', 'Y'), nullable=False, server_default=text("'N'"))
    Lock_tables_priv = Column(ENUM('N', 'Y'), nullable=False, server_default=text("'N'"))
    Execute_priv = Column(ENUM('N', 'Y'), nullable=False, server_default=text("'N'"))
    Repl_slave_priv = Column(ENUM('N', 'Y'), nullable=False, server_default=text("'N'"))
    Repl_client_priv = Column(ENUM('N', 'Y'), nullable=False, server_default=text("'N'"))
    Create_view_priv = Column(ENUM('N', 'Y'), nullable=False, server_default=text("'N'"))
    Show_view_priv = Column(ENUM('N', 'Y'), nullable=False, server_default=text("'N'"))
    Create_routine_priv = Column(ENUM('N', 'Y'), nullable=False, server_default=text("'N'"))
    Alter_routine_priv = Column(ENUM('N', 'Y'), nullable=False, server_default=text("'N'"))
    Create_user_priv = Column(ENUM('N', 'Y'), nullable=False, server_default=text("'N'"))
    Event_priv = Column(ENUM('N', 'Y'), nullable=False, server_default=text("'N'"))
    Trigger_priv = Column(ENUM('N', 'Y'), nullable=False, server_default=text("'N'"))
    Create_tablespace_priv = Column(ENUM('N', 'Y'), nullable=False, server_default=text("'N'"))
    ssl_type = Column(ENUM('', 'ANY', 'X509', 'SPECIFIED'), nullable=False, server_default=text("''"))
    ssl_cipher = Column(LargeBinary, nullable=False)
    x509_issuer = Column(LargeBinary, nullable=False)
    x509_subject = Column(LargeBinary, nullable=False)
    max_questions = Column(INTEGER(11), nullable=False, server_default=text("'0'"))
    max_updates = Column(INTEGER(11), nullable=False, server_default=text("'0'"))
    max_connections = Column(INTEGER(11), nullable=False, server_default=text("'0'"))
    max_user_connections = Column(INTEGER(11), nullable=False, server_default=text("'0'"))
    plugin = Column(CHAR(64, 'utf8_bin'), nullable=False, server_default=text("'mysql_native_password'"))
    authentication_string = Column(Text(collation='utf8_bin'))
    password_expired = Column(ENUM('N', 'Y'), nullable=False, server_default=text("'N'"))
    password_last_changed = Column(TIMESTAMP)
    password_lifetime = Column(SMALLINT(5))
    account_locked = Column(ENUM('N', 'Y'), nullable=False, server_default=text("'N'"))
Ejemplo n.º 9
0
class User(UserMixin, Base):

    __tablename__ = 'users'

    id = Column(INTEGER(), primary_key=True, unique=True)
    first_name = Column(String(255), nullable=False)
    last_name = Column(String(255), nullable=False)
    user_name = Column(String(255), nullable=False, unique=True)
    password = Column(String(255), nullable=False)
    email_id = Column(String(255), nullable=False, unique=True)
    privilege = Column(INTEGER(), nullable=False, server_default=text("'0'"))
    projects = relationship('Project',
                            secondary=t_users_has_projects,
                            backref=db.backref('projects'),
                            cascade="delete")
    created_at = Column(DateTime)
    updated_at = Column(DateTime)

    def __init__(self, **kwargs):
        current_time = time.strftime('%Y-%m-%d %H:%M:%S')

        self.first_name = kwargs["first_name"]
        self.last_name = kwargs["last_name"]
        self.user_name = kwargs["user_name"]
        self.password = kwargs["password"]
        self.email_id = kwargs["email_id"]
        self.privilege = 0
        self.created_at = current_time
        self.updated_at = current_time

    def json(self):
        serialized_projects = list()

        for project in self.projects:
            serialized_projects.append({'id': project.id, \
                                        'status': project.status, \
                                        'name': project.name \
            })

        return {'id': self.id, \
               'firstName': self.first_name,\
               'lastName': self.last_name,\
               'userName': self.user_name,\
               'emailId': self.email_id,\
               'privilege': self.privilege,\
               'projects': serialized_projects,\
               'createdAt': self.created_at, \
               'updatedAt': self.updated_at }
Ejemplo n.º 10
0
class ScheduledTransaction(DeclarativeBaseGuid):
    """
    A GnuCash Scheduled Transaction.

    Attributes
        adv_creation (int) : days to create in advance (0 if disabled)
        adv_notify (int) : days to notify in advance (0 if disabled)
        auto_create (bool) :
        auto_notify (bool) :
        enabled (bool) :
        start_date (:class:`datetime.datetime`) : date to start the scheduled transaction
        last_occur (:class:`datetime.datetime`) : date of last occurence of the schedule transaction
        end_date (:class:`datetime.datetime`) : date to end the scheduled transaction (num/rem_occur should be 0)
        instance_count (int) :
        name (str) : name of the scheduled transaction
        num_occur (int) : number of occurences in total (end_date should be null)
        rem_occur (int) : number of remaining occurences (end_date should be null)
        template_account (:class:`piecash.core.account.Account`): template account of the transaction
    """
    __tablename__ = 'schedxactions'

    __table_args__ = {}

    # column definitions
    guid = Column('guid',
                  VARCHAR(length=32),
                  primary_key=True,
                  nullable=False,
                  default=lambda: uuid.uuid4().hex)
    name = Column('name', VARCHAR(length=2048))
    enabled = Column('enabled', INTEGER(), nullable=False)
    start_date = Column('start_date', _Date())
    end_date = Column('end_date', _Date())
    last_occur = Column('last_occur', _Date())
    num_occur = Column('num_occur', INTEGER(), nullable=False)
    rem_occur = Column('rem_occur', INTEGER(), nullable=False)
    auto_create = Column('auto_create', INTEGER(), nullable=False)
    auto_notify = Column('auto_notify', INTEGER(), nullable=False)
    adv_creation = Column('adv_creation', INTEGER(), nullable=False)
    adv_notify = Column('adv_notify', INTEGER(), nullable=False)
    instance_count = Column('instance_count', INTEGER(), nullable=False)
    template_act_guid = Column('template_act_guid',
                               VARCHAR(length=32),
                               ForeignKey('accounts.guid'),
                               nullable=False)

    # relation definitions
    template_account = relation('Account')
    recurrence = relation(
        'Recurrence',
        primaryjoin=guid == foreign(Recurrence.obj_guid),
        cascade='all, delete-orphan',
        uselist=False,
    )

    def __unirepr__(self):
        return u"ScheduledTransaction<'{}' {}>".format(self.name,
                                                       self.recurrence)
Ejemplo n.º 11
0
class Issue(Base):
    __tablename__ = 'issues'

    id = Column(INTEGER(), primary_key=True, unique=True)
    subject = Column(String(45), nullable=False)
    description = Column(String(255))
    priority = Column(INTEGER(), nullable=False, server_default=text("'0'"))
    projects_id = Column(ForeignKey('projects.id'), nullable=False, index=True)
    created_by_user_id = Column(ForeignKey('users.id'),
                                nullable=False,
                                index=True)
    assigned_to_user_id = Column(ForeignKey('users.id'),
                                 nullable=False,
                                 index=True)
    created_at = Column(DateTime, nullable=False)
    updated_at = Column(DateTime, nullable=False)
    status = Column(INTEGER(), nullable=False, server_default=text("'0'"))
    tested = Column(INTEGER(), server_default=text("'0'"))

    assigned_to_user = relationship(
        'User', primaryjoin='Issue.assigned_to_user_id == User.id')
    created_by_user = relationship(
        'User', primaryjoin='Issue.created_by_user_id == User.id')
    projects = relationship('Project')

    def __init__(self, **kwargs):
        current_time = time.strftime('%Y-%m-%d %H:%M:%S')

        self.subject = kwargs["subject"]
        self.description = kwargs["description"]
        self.projects_id = kwargs["projects_id"]
        self.created_by_user_id = kwargs["created_by_user_id"]
        self.assigned_to_user_id = kwargs["assigned_to_user_id"]
        self.status = kwargs["status"]
        self.created_at = current_time
        self.updated_at = current_time

    def json(self):
        return {'id': self.id, \
                 'subject': self.subject,\
                 'description': self.description,\
                 'priority': self.priority,\
                 'projectsId': self.projects_id,\
                 'createdByUser': db.session.query(User.email_id).filter((User.id == self.created_by_user_id)).first()[0], \
                 'assignedToUser': db.session.query(User.email_id).filter((User.id == self.assigned_to_user_id)).first()[0],\
                 'status': self.status, \
                 'createdAt': self.created_at, \
                 'updatedAt': self.updated_at }
Ejemplo n.º 12
0
async def subtree(request):
    """
    ---
    tags:
    - tree
    summary: Get subtree
    produces:
    - application/json
    parameters:
    - in: path
      name: id
      required: true
      type: string
    responses:
      "200":
        description:
    """
    item_id = int(request.match_info.get('id'))

    item = await get_node(node_id=item_id, db=request.app['db'])
    if not item:
        return web.HTTPNotFound()

    async with request.app['db'].acquire() as conn:
        data = [
            dict(row.items())
            async for row in conn.execute(tree_table.select().where(
                and_(
                    tree_table.c.id != item_id,
                    array([tree_table.c.id]).overlap(
                        cast(item.path, ARRAY(INTEGER()))))).order_by(
                            tree_table.c.path))
        ]

    return web.HTTPOk(text=json.dumps(data), content_type='application/json')
Ejemplo n.º 13
0
class Player(Base):
    __tablename__ = 'player'

    player_code = Column(String(10, 'utf8mb4_unicode_ci'),
                         primary_key=True,
                         nullable=False)
    name = Column(String(50, 'utf8mb4_unicode_ci'), nullable=False)
    al_name = Column(String(50, 'utf8mb4_unicode_ci'), nullable=False)
    uniform_number = Column(String(12, 'utf8mb4_unicode_ci'), nullable=False)
    comment = Column(String(1024, 'utf8mb4_unicode_ci'), nullable=False)
    birthday = Column(Date)
    status = Column(String(1, 'utf8mb4_unicode_ci'), nullable=False)
    course_count = Column(INTEGER(), nullable=False)
    due_dt = Column(Date)
    group = Column(String(6, 'utf8mb4_unicode_ci'), nullable=False)
    contact_phone = Column(String(32, 'utf8mb4_unicode_ci'), nullable=False)
    contact_name = Column(String(50, 'utf8mb4_unicode_ci'), nullable=False)
    d1 = Column(String(32, 'utf8mb4_unicode_ci'), nullable=False)
    d2 = Column(String(32, 'utf8mb4_unicode_ci'), nullable=False)
    d3 = Column(String(32, 'utf8mb4_unicode_ci'), nullable=False)
    d4 = Column(String(32, 'utf8mb4_unicode_ci'), nullable=False)
    d5 = Column(String(32, 'utf8mb4_unicode_ci'), nullable=False)
    d6 = Column(String(32, 'utf8mb4_unicode_ci'), nullable=False)
    d7 = Column(String(32, 'utf8mb4_unicode_ci'), nullable=False)
    batch_id = Column(String(20, 'utf8mb4_unicode_ci'),
                      server_default=text("''"),
                      nullable=False)
Ejemplo n.º 14
0
class Requirement(Base):
    """
    This class is mapped to the requirement table in the Management schema.
    DB Comment: Mapping to TFS requirements. Since not all automated test cases may be found in TFS,
    traceability must be ensured internally.
    """
    __tablename__ = 'requirement'
    __table_args__ = {'schema': schema}

    req_id = Column(INTEGER(), primary_key=True, nullable=False)
    """Internal requirement ID."""
    title = Column(VARCHAR(length=2000), nullable=False)
    """Maps to TFS work item title."""
    tfs_link = Column(VARCHAR(length=2000))
    """Link to the work item in TFS."""
    tfs_id = Column(VARCHAR(length=250))
    """Maps to TFS ID."""
    mrd = Column(VARCHAR(length=250))
    """If the requirement is an SRD/TRD, this links it to the parent marketing requirement."""
    feature = Column(VARCHAR(length=2000))
    """Links the requirement to the parent feature. (Where applicable)"""
    req_type = Column(VARCHAR(length=10))
    """MRD, SRD, TRD or Backlog Item."""
    req_version = Column(REAL(precision=8, decimal_return_scale=8),
                         primary_key=True,
                         nullable=False,
                         server_default=DefaultClause("1.0", for_update=False))
    """The requirement version as it is stored in TFS, where applicable. Set to default for backlog items."""
Ejemplo n.º 15
0
class Employee(DeclarativeBaseGuid):
    __tablename__ = 'employees'

    __table_args__ = {}

    # column definitions
    username = Column('username', VARCHAR(length=2048), nullable=False)
    id = Column('id', VARCHAR(length=2048), nullable=False)
    language = Column('language', VARCHAR(length=2048), nullable=False)
    acl = Column('acl', VARCHAR(length=2048), nullable=False)
    active = Column('active', INTEGER(), nullable=False)
    currency_guid = Column('currency', VARCHAR(length=32), ForeignKey('commodities.guid'),nullable=False)
    ccard_guid = Column('ccard_guid', VARCHAR(length=32), ForeignKey('accounts.guid'))
    _workday_num = Column('workday_num', BIGINT(), nullable=False)
    _workday_denom = Column('workday_denom', BIGINT(), nullable=False)
    workday = hybrid_property_gncnumeric(_workday_num, _workday_denom)
    _rate_num = Column('rate_num', BIGINT(), nullable=False)
    _rate_denom = Column('rate_denom', BIGINT(), nullable=False)
    rate = hybrid_property_gncnumeric(_rate_num, _rate_denom)
    
    addr_name = Column('addr_name', VARCHAR(length=1024))
    addr_addr1 = Column('addr_addr1', VARCHAR(length=1024))
    addr_addr2 = Column('addr_addr2', VARCHAR(length=1024))
    addr_addr3 = Column('addr_addr3', VARCHAR(length=1024))
    addr_addr4 = Column('addr_addr4', VARCHAR(length=1024))
    addr_phone = Column('addr_phone', VARCHAR(length=128))
    addr_fax = Column('addr_fax', VARCHAR(length=128))
    addr_email = Column('addr_email', VARCHAR(length=256))
    addr = composite(Address, addr_addr1, addr_addr2, addr_addr3, addr_addr4,
                     addr_email, addr_fax, addr_name, addr_phone)

    # relation definitions
    currency= relation('Commodity')
    credit_account = relation('Account')
Ejemplo n.º 16
0
class TCode(Base):
    __tablename__ = 't_code'

    tid = Column(INTEGER(), primary_key=True)
    code = Column(String(50))
    code_desc = Column(String(50))
    code_val = Column(String(50))
Ejemplo n.º 17
0
class Taxtable(DeclarativeBaseGuid):
    __tablename__ = 'taxtables'

    __table_args__ = {}

    # column definitions
    guid = Column('guid', VARCHAR(length=32), primary_key=True, nullable=False, default=lambda: uuid.uuid4().hex)
    name = Column('name', VARCHAR(length=50), nullable=False)
    refcount = Column('refcount', BIGINT(), nullable=False)
    invisible = Column('invisible', INTEGER(), nullable=False)
    parent_guid = Column('parent', VARCHAR(length=32), ForeignKey('taxtables.guid'))

    # relation definitions
    entries = relation('TaxtableEntry',
                       back_populates='taxtable',
                       cascade='all, delete-orphan',
                       collection_class=CallableList,
    )
    children = relation('Taxtable',
                        back_populates='parent',
                        cascade='all, delete-orphan',
                        collection_class=CallableList,
    )
    parent = relation('Taxtable',
                      back_populates='children',
                      remote_side=guid,
    )
Ejemplo n.º 18
0
class Role(db.Model):
    """
        角色表
    """
    __tablename__ = "Role"

    role_id = db.Column(
        "role_id",
        INTEGER,
        primary_key=True,
        nullable=False,
        autoincrement=True,
        doc="value is 1 means it is admin which has all permissions")
    role_name = db.Column("role_name", VARCHAR(255), nullable=False)
    create_time = db.Column("create_time",
                            TIMESTAMP,
                            nullable=False,
                            server_default=func.now)
    status = db.Column("status", INTEGER(), default=1)  # 角色状态, 1.正常 0.停用

    def __init__(self, role_name):
        self.role_name = role_name

    @classmethod
    def insert(cls, role_name):
        one = cls(role_name)
        db.session.add(one)
        db.session.commit()
Ejemplo n.º 19
0
class Face(db.Model):

    id = Column(INTEGER(), primary_key=True, autoincrement=True)
    name = Column(String(256))
    path = Column(String(1024))
    is_train = Column(SmallInteger)
    encoding = Column(String(2048))
    dataset = Column(String(256))

    def __init__(self, name, path, dataset, is_train=False):
        self.name = name
        self.path = path
        self.is_train = is_train
        self.dataset = dataset
        self.data = None

    def save(self):
        db.session.add(self)
        db.session.commit()

    def get_org_data(self):
        with open(self.path, 'rb') as f:
            img = f.read()
        img_b64 = base64.b64encode(img)
        self.data = 'data:image/gif;base64,%s' % str(img_b64, 'utf-8')

    def get_rec_data(self):
        self.data = face_rec_rpc(str(self.id))

    def record_train(self):
        self.is_train = True
        self.save()
Ejemplo n.º 20
0
    def test_custom_type_compare(self):
        class MyType(TypeDecorator):
            impl = Integer

            def compare_against_backend(self, dialect, conn_type):
                return isinstance(conn_type, Integer)

        ac = ops.AlterColumnOp("sometable", "somecol")
        autogenerate.compare._compare_type(
            self.autogen_context,
            ac,
            None,
            "sometable",
            "somecol",
            Column("somecol", INTEGER()),
            Column("somecol", MyType()),
        )

        assert not ac.has_changes()

        ac = ops.AlterColumnOp("sometable", "somecol")
        autogenerate.compare._compare_type(
            self.autogen_context,
            ac,
            None,
            "sometable",
            "somecol",
            Column("somecol", String()),
            Column("somecol", MyType()),
        )
        diff = ac.to_diff_tuple()
        eq_(diff[0][0:4], ('modify_type', None, 'sometable', 'somecol'))
Ejemplo n.º 21
0
class TimeZone(SAFRSBase, Base):
    __tablename__ = "time_zone"

    Time_zone_id = Column(INTEGER(10), primary_key=True)
    Use_leap_seconds = Column(Enum("Y", "N"),
                              nullable=False,
                              server_default=text("'N'"))
Ejemplo n.º 22
0
class TaxtableEntry(DeclarativeBase):
    __tablename__ = 'taxtable_entries'

    __table_args__ = {'sqlite_autoincrement': True}

    # column definitions
    id = Column('id', INTEGER(), primary_key=True, nullable=False)
    taxtable_guid = Column('taxtable', VARCHAR(length=32),
                           ForeignKey('taxtables.guid'), nullable=False)
    account_guid = Column('account', VARCHAR(length=32), ForeignKey('accounts.guid'), nullable=False)
    _amount_num = Column('amount_num', BIGINT(), nullable=False)
    _amount_denom = Column('amount_denom', BIGINT(), nullable=False)
    amount = hybrid_property_gncnumeric(_amount_num, _amount_denom)
    type = Column('type', ChoiceType({1: "value", 2: "percentage"}), nullable=False)

    # relation definitions
    taxtable = relation('Taxtable', back_populates='entries')
    account = relation('Account')

    def __init__(self, type, amount, account, taxtable=None):
        self.type = type
        self.amount = amount
        self.account = account
        if taxtable:
            self.taxtable = taxtable

    def __unirepr__(self):
        return u"TaxEntry<{} {} in {}>".format(self.amount, self.type, self.account.name)
Ejemplo n.º 23
0
class Message(Base):
    __tablename__ = 'messages'

    id = Column(INTEGER(), primary_key=True)
    msg = Column(String(255), nullable=False)
    users_id = Column(ForeignKey('users.id'), nullable=False, index=True)
    projects_id = Column(ForeignKey('projects.id'), nullable=False, index=True)
    created_at = Column(DateTime)
    stored_at = Column(DateTime)

    projects = relationship('Project')
    users = relationship('User')

    def __init__(self, **data):
        current_time = time.strftime('%Y-%m-%d %H:%M:%S')

        self.msg = data['msg']
        self.users_id = data['user_id']
        self.projects_id = data['project_id']
        self.created_at = data['created_at']
        self.stored_at = current_time

    def json(self):
        return {"msg": self.msg,\
                "userId": self.users_id,\
                "createdAt": self.created_at
               }
Ejemplo n.º 24
0
class User(Base):
    __tablename__ = 'user'

    user_id = Column(String(40), primary_key=True)
    user_name = Column(String(40), nullable=False)
    real_name = Column(String(40))
    mobile = Column(INTEGER(11), nullable=False)
    email = Column(String(40))
    birthday = Column(String(40))
    province = Column(String(40))
    city = Column(String(40))
    area = Column(String(200))
    images = Column(String(400))
    status = Column(INTEGER(40), nullable=False, server_default=text("'0'"))
    created = Column(DateTime, nullable=False)
    updated = Column(DateTime)
Ejemplo n.º 25
0
class SlaveWorkerInfo(SAFRSBase, Base):
    __tablename__ = "slave_worker_info"

    Id = Column(INTEGER(10), primary_key=True, nullable=False)
    Relay_log_name = Column(TEXT, nullable=False)
    Relay_log_pos = Column(BIGINT(20), nullable=False)
    Master_log_name = Column(TEXT, nullable=False)
    Master_log_pos = Column(BIGINT(20), nullable=False)
    Checkpoint_relay_log_name = Column(TEXT, nullable=False)
    Checkpoint_relay_log_pos = Column(BIGINT(20), nullable=False)
    Checkpoint_master_log_name = Column(TEXT, nullable=False)
    Checkpoint_master_log_pos = Column(BIGINT(20), nullable=False)
    Checkpoint_seqno = Column(INTEGER(10), nullable=False)
    Checkpoint_group_size = Column(INTEGER(10), nullable=False)
    Checkpoint_group_bitmap = Column(LargeBinary, nullable=False)
    Channel_name = Column(CHAR(64), primary_key=True, nullable=False)
Ejemplo n.º 26
0
class Rental(SAFRSBase, Base):
    __tablename__ = "rental"
    __table_args__ = (Index("rental_date",
                            "rental_date",
                            "inventory_id",
                            "customer_id",
                            unique=True), )

    rental_id = Column(INTEGER(11), primary_key=True)
    rental_date = Column(DateTime, nullable=False)
    inventory_id = Column(ForeignKey("inventory.inventory_id",
                                     onupdate="CASCADE"),
                          nullable=False,
                          index=True)
    customer_id = Column(ForeignKey("customer.customer_id",
                                    onupdate="CASCADE"),
                         nullable=False,
                         index=True)
    return_date = Column(DateTime)
    staff_id = Column(ForeignKey("staff.staff_id", onupdate="CASCADE"),
                      nullable=False,
                      index=True)
    last_update = Column(
        TIMESTAMP,
        nullable=False,
        server_default=text("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"))

    customer = relationship("Customer")
    inventory = relationship("Inventory")
    staff = relationship("Staff")
Ejemplo n.º 27
0
class Book(Base):

    __tablename__ = 'book'

    id = Column(INTEGER(), primary_key=True)
    name = Column(String(11))
    author = Column(String(11))
Ejemplo n.º 28
0
class Recipe(Base):
    __tablename__ = 'recipe'
    id = Column(INTEGER(unsigned=True), primary_key=True)
    name = Column(CHAR(100), nullable=False, index=True)
    #picture = Column(String(4096), nullable=False, doc='具体照片: ["xxx.jpg", "xxx2.jpg"], 数组中是大图路径,小图路径可')
    cover = Column(String(255), nullable=False, doc='一个小图的封面,用于列表展示的时候读取')
    #intro = Column(String(2048), nullable=True, doc='简介')
    #main_material = Column(String(2048), nullable=True, doc='主料,json格式,{"鸡肉": "200克",.....}')
    #condiment = Column(String(1024), nullable=True, doc='辅料,json格式')
    #procedure = Column(Text, nullable=True, doc='过程,json')
    orig_id = Column(INTEGER, nullable=False, index=True)
    view = Column(INTEGER, nullable=False, default=0)
    like = Column(INTEGER, nullable=False, default=0)
    favor = Column(INTEGER, nullable=False, default=0)
    date_add = Column(DateTime, nullable=True)
    date_upd = Column(DateTime, nullable=True)
    #tips = Column(Text, nullable=True)
    #tool = Column(CHAR(40), nullable=True)
    # many to many
    categories = relationship("Category",
                              secondary=recipe_category,
                              backref="recipes")
    materials = relationship("Material",
                             secondary=recipe_material,
                             backref="recipes")
    collections = relationship("Collection",
                               secondary=recipe_collection,
                               backref="recipes")
Ejemplo n.º 29
0
class Rental(SAFRSBase, Base):
    __tablename__ = 'rental'
    __table_args__ = (Index('rental_date',
                            'rental_date',
                            'inventory_id',
                            'customer_id',
                            unique=True), )

    rental_id = Column(INTEGER(11), primary_key=True)
    rental_date = Column(DateTime, nullable=False)
    inventory_id = Column(ForeignKey('inventory.inventory_id',
                                     onupdate='CASCADE'),
                          nullable=False,
                          index=True)
    customer_id = Column(ForeignKey('customer.customer_id',
                                    onupdate='CASCADE'),
                         nullable=False,
                         index=True)
    return_date = Column(DateTime)
    staff_id = Column(ForeignKey('staff.staff_id', onupdate='CASCADE'),
                      nullable=False,
                      index=True)
    last_update = Column(
        TIMESTAMP,
        nullable=False,
        server_default=text("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"))

    customer = relationship('Customer')
    inventory = relationship('Inventory')
    staff = relationship('Staff')
Ejemplo n.º 30
0
class Client(Base):
    __tablename__ = 'client'

    id_client = Column(INTEGER(10), primary_key=True)
    client = Column(String(20),
                    nullable=False,
                    index=True,
                    server_default=text("''"))
    siret = Column(String(30))
    raison_soc = Column(String(255))
    adresse = Column(String(255))
    cp = Column(String(15))
    ville = Column(String(100))
    tel = Column(String(25))
    fax = Column(String(25))
    email = Column(String(100))
    contact_titre = Column(String(100))
    contact_nom = Column(LargeBinary)
    contact_fonction = Column(LargeBinary)
    contact_tel = Column(LargeBinary)
    contact_port = Column(LargeBinary)
    contact_fax = Column(LargeBinary)
    contact_email = Column(LargeBinary)
    police_flot = Column(CHAR(1))
    cond_regl = Column(TINYINT(3))
    obs = Column(LargeBinary)
    stat_cli = Column(CHAR(1))