Exemplo n.º 1
0
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('SourcingVendorDetail',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('dname', sa.String(), nullable=False),
    sa.Column('currency_code', sa.String(), nullable=False),
    sa.Column('currency_symbol', sa.String(), nullable=False),
    sa.Column('vendor_id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['vendor_id'], ['SourcingVendor.id'], ),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('vendor_id')
    )
    op.create_table('VendorElnPartDetail',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('package', sa.String(), nullable=False),
    sa.Column('datasheet', sa.String(), nullable=False),
    sa.Column('vpno_id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['vpno_id'], ['VendorPartNumber.id'], ),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('vpno_id')
    )
    op.create_table('VendorPartDetail',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('created_at', ArrowType(), nullable=True),
    sa.Column('updated_at', ArrowType(), nullable=True),
    sa.Column('vqtyavail', sa.Integer(), nullable=True),
    sa.Column('manufacturer', sa.String(), nullable=True),
    sa.Column('mpartno', sa.String(), nullable=True),
    sa.Column('vpartdesc', sa.String(), nullable=True),
    sa.Column('pkgqty', sa.Integer(), nullable=True),
    sa.Column('vpno_id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['vpno_id'], ['VendorPartNumber.id'], ),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('vpno_id')
    )
    op.create_table('VendorPrice',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('created_at', ArrowType(), nullable=True),
    sa.Column('updated_at', ArrowType(), nullable=True),
    sa.Column('moq', sa.Integer(), nullable=False),
    sa.Column('price', sa.String(), nullable=False),
    sa.Column('oqmultiple', sa.Integer(), nullable=False),
    sa.Column('vpno_id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['vpno_id'], ['VendorPartNumber.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.alter_column(u'VendorPartMap', 'vendor_id',
               existing_type=sa.INTEGER(),
               nullable=False)
    op.alter_column(u'VendorPartNumber', 'vpmap_id',
               existing_type=sa.INTEGER(),
               nullable=False)
Exemplo n.º 2
0
class User(db.Model):
    __tablename__ = 'users'
    id = Column(Integer, primary_key=True)
    password = Column(String(128))
    active = Column(Boolean())
    confirmed_at = Column(ArrowType())
    username = Column(String(255), nullable=False, unique=True)
    email = Column(String(128), unique=True)
    profile_picture = Column(String(255))
    roles = relationship('Role',
                         secondary=roles_users,
                         passive_deletes=True,
                         backref=db.backref('user'),
                         lazy='dynamic')
    certificates = relationship('Certificate',
                                backref=db.backref('user'),
                                lazy='dynamic')
    authorities = relationship('Authority',
                               backref=db.backref('user'),
                               lazy='dynamic')
    keys = relationship('ApiKey', backref=db.backref('user'), lazy='dynamic')
    logs = relationship('Log', backref=db.backref('user'), lazy='dynamic')

    sensitive_fields = ('password', )

    def check_password(self, password):
        """
        Hash a given password and check it against the stored value
        to determine it's validity.

        :param password:
        :return:
        """
        if self.password:
            return bcrypt.check_password_hash(self.password, password)

    def hash_password(self):
        """
        Generate the secure hash for the password.

        :return:
        """
        if self.password:
            self.password = bcrypt.generate_password_hash(
                self.password).decode('utf-8')

    @property
    def is_admin(self):
        """
        Determine if the current user has the 'admin' role associated
        with it.

        :return:
        """
        for role in self.roles:
            if role.name == 'admin':
                return True

    def __repr__(self):
        return "User(username={username})".format(username=self.username)
Exemplo n.º 3
0
class Log(db.Model):
    __tablename__ = 'logs'
    id = Column(Integer, primary_key=True)
    certificate_id = Column(Integer, ForeignKey('certificates.id'))
    log_type = Column(Enum('key_view', 'create_cert', 'update_cert', 'revoke_cert', 'delete_cert', name='log_type'), nullable=False)
    logged_at = Column(ArrowType(), PassiveDefault(func.now()), nullable=False)
    user_id = Column(Integer, ForeignKey('users.id'), nullable=False)
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        'SourcingVendor', sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('name', sa.String(), nullable=False),
        sa.Column('dname', sa.String(), nullable=True),
        sa.Column('type', sa.String(), nullable=False),
        sa.Column('mapfile_base', sa.String(), nullable=False),
        sa.Column('pclass_str', sa.String(), nullable=False),
        sa.Column('status',
                  sa.Enum('active',
                          'suspended',
                          'defunct',
                          name='vendor_status'),
                  server_default='active',
                  nullable=False), sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint('mapfile_base'), sa.UniqueConstraint('name'))
    op.create_table(
        'VendorPartMap', sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('created_at', ArrowType(), nullable=True),
        sa.Column('ident', sa.String(), nullable=False),
        sa.Column('strategy', sa.String(), nullable=True),
        sa.Column('vendor_id', sa.Integer(), nullable=True),
        sa.ForeignKeyConstraint(
            ['vendor_id'],
            ['SourcingVendor.id'],
        ), sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint('vendor_id', 'ident',
                            name='constraint_vmap_ident'))
    op.create_table(
        'VendorPartNumber', sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('created_at', ArrowType(), nullable=True),
        sa.Column('vpno', sa.String(), nullable=False),
        sa.Column('type',
                  sa.Enum('auto', 'manual', name='map_type'),
                  server_default='auto',
                  nullable=False),
        sa.Column('vpmap_id', sa.Integer(), nullable=True),
        sa.ForeignKeyConstraint(
            ['vpmap_id'],
            ['VendorPartMap.id'],
        ), sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint('vpmap_id', 'vpno', name='constraint_vmap_vpno'))
Exemplo n.º 5
0
class Log(db.Model):
    __tablename__ = "logs"
    id = Column(Integer, primary_key=True)
    certificate_id = Column(Integer, ForeignKey("certificates.id"))
    log_type = Column(
        Enum(
            "key_view",
            "create_cert",
            "update_cert",
            "revoke_cert",
            "delete_cert",
            name="log_type",
        ),
        nullable=False,
    )
    logged_at = Column(ArrowType(), DefaultClause(func.now()), nullable=False)
    user_id = Column(Integer, ForeignKey("users.id"), nullable=False)
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('DocStoreDocument',
                  sa.Column('updated_at', ArrowType(), nullable=True))
    op.add_column('SerialNumber',
                  sa.Column('updated_at', ArrowType(), nullable=True))
    op.add_column('SerialNumberAssociation',
                  sa.Column('updated_at', ArrowType(), nullable=True))
    op.add_column('TestResult',
                  sa.Column('updated_at', ArrowType(), nullable=True))
    op.add_column('TestSuiteResult',
                  sa.Column('updated_at', ArrowType(), nullable=True))
    op.add_column('VendorPartMap',
                  sa.Column('updated_at', ArrowType(), nullable=True))
    op.add_column('VendorPartNumber',
                  sa.Column('updated_at', ArrowType(), nullable=True))
Exemplo n.º 7
0
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        'platform',
        sa.Column('id', HackyUUIDType(), nullable=False),
        sa.Column('name', sa.Text(), nullable=False),
        sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint('id'),
        sa.UniqueConstraint('name'),
    )
    op.create_table(
        'release',
        sa.Column('id', HackyUUIDType(), nullable=False),
        sa.Column('references', sa.String(), nullable=True),
        sa.Column('stime', ArrowType(), nullable=True),
        sa.Column('ftime', ArrowType(), nullable=True),
        sa.Column('duration', sa.Interval(), nullable=True),
        sa.Column('user', sa.String(), nullable=False),
        sa.Column('team', sa.String(), nullable=True),
        sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint('id'),
    )
    op.create_index(op.f('ix_release_stime'), 'release', ['stime'], unique=False)
    op.create_table(
        'package',
        sa.Column('id', HackyUUIDType(), nullable=False),
        sa.Column('name', sa.String(length=120), nullable=False),
        sa.Column('stime', ArrowType(), nullable=True),
        sa.Column('ftime', ArrowType(), nullable=True),
        sa.Column('duration', sa.Interval(), nullable=True),
        sa.Column('status', sa.Enum('NOT_STARTED', 'IN_PROGRESS', 'SUCCESSFUL', 'FAILED', name='status_types'), nullable=True),
        sa.Column('version', sa.String(length=32), nullable=False),
        sa.Column('diff_url', sa.String(), nullable=True),
        sa.Column('rollback', sa.Boolean(), nullable=True),
        sa.Column('release_id', HackyUUIDType(), nullable=True),
        sa.ForeignKeyConstraint(['release_id'], ['release.id'], ),
        sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint('id'),
    )

    op.create_index(op.f('ix_package_stime'), 'package', ['stime'], unique=False)
    op.create_table(
        'release_metadata',
        sa.Column('id', HackyUUIDType(), nullable=False),
        sa.Column('release_id', HackyUUIDType(), nullable=True),
        sa.Column('key', sa.Text(), nullable=False),
        sa.Column('value', sa.Text(), nullable=False),
        sa.ForeignKeyConstraint(['release_id'], ['release.id'], ),
        sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint('id'),
    )
    op.create_table(
        'release_note',
        sa.Column('id', HackyUUIDType(), nullable=False),
        sa.Column('content', sa.Text(), nullable=False),
        sa.Column('release_id', HackyUUIDType(), nullable=True),
        sa.ForeignKeyConstraint(['release_id'], ['release.id'], ),
        sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint('id'),
    )
    op.create_table(
        'release_platform',
        sa.Column('release_id', HackyUUIDType(), nullable=True),
        sa.Column('platform_id', HackyUUIDType(), nullable=True),
        sa.ForeignKeyConstraint(['platform_id'], ['platform.id'], ),
        sa.ForeignKeyConstraint(['release_id'], ['release.id'], ),
    )

    op.create_table(
        'package_result',
        sa.Column('id', HackyUUIDType(), nullable=False),
        sa.Column('content', sa.Text(), nullable=True),
        sa.Column('package_id', HackyUUIDType(), nullable=True),
        sa.ForeignKeyConstraint(['package_id'], ['package.id'], ),
        sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint('id'),
    )