Пример #1
0
class CVEGroupEntry(db.Model):

    __tablename__ = 'cve_group_entry'
    __versioned__ = {}

    id = db.Column(db.Integer(),
                   index=True,
                   unique=True,
                   primary_key=True,
                   autoincrement=True)
    group_id = db.Column(db.Integer(),
                         db.ForeignKey('cve_group.id', ondelete="CASCADE"),
                         nullable=False)
    cve_id = db.Column(db.String(15),
                       db.ForeignKey('cve.id', ondelete="CASCADE"),
                       nullable=False)

    group = db.relationship("CVEGroup", back_populates="issues")
    cve = db.relationship("CVE")

    __table_args__ = (db.Index('cve_group_entry__group_cve_idx',
                               group_id,
                               cve_id,
                               unique=True), )

    def __repr__(self):
        return '<CVEGroupEntry %r from %r referencing %r>' % (
            self.id, self.group_id, self.cve_id)
Пример #2
0
class Membership(db.Model):
    __tablename__ = "memberships"

    id = db.Column(db.Integer, primary_key=True)
    user_id = db.Column(db.Integer, db.ForeignKey("users.id"))
    group_id = db.Column(db.Integer, db.ForeignKey("groups.id"))

    user = orm.relationship(User,
                            backref=orm.backref("orders",
                                                cascade="all, delete-orphan"))
    group = orm.relationship(Group,
                             backref=orm.backref("groups",
                                                 cascade="all, delete-orphan"))
Пример #3
0
class Advisory(db.Model):
    WORKAROUND_LENGTH = 4096
    IMPACT_LENGTH = 4096
    CONTENT_LENGTH = 65536
    REFERENCE_LENGTH = 120

    __tablename__ = 'advisory'
    id = db.Column(db.String(15), index=True, unique=True, primary_key=True)
    group_package_id = db.Column(db.Integer(),
                                 db.ForeignKey('cve_group_package.id'),
                                 nullable=False,
                                 unique=True,
                                 index=True)
    advisory_type = db.Column(db.String(64),
                              default='multiple issues',
                              nullable=False)
    publication = db.Column(Publication.as_type(),
                            nullable=False,
                            default=Publication.scheduled)
    workaround = db.Column(db.String(WORKAROUND_LENGTH), nullable=True)
    impact = db.Column(db.String(IMPACT_LENGTH), nullable=True)
    content = db.Column(db.String(CONTENT_LENGTH), nullable=True)
    created = db.Column(db.DateTime,
                        default=datetime.utcnow,
                        nullable=False,
                        index=True)
    reference = db.Column(db.String(REFERENCE_LENGTH), nullable=True)

    group_package = db.relationship("CVEGroupPackage")

    def __repr__(self):
        return '<Advisory {}>'.format(self.id)
Пример #4
0
class Address(db.Model):
    __tablename__ = "addresses"

    id = db.Column(db.Integer, primary_key=True)
    address = db.Column(db.String(40), unique=True)
    user_id = db.Column(db.Integer, db.ForeignKey("users.id"))
    final_balance = db.Column(db.Integer)
Пример #5
0
class AddressTransaction(db.Model):
    __tablename__ = "address_transactions"

    id = db.Column(db.Integer, primary_key=True)
    address_id = db.Column(db.Integer, db.ForeignKey("addresses.id"))
    transaction_id = db.Column(db.Integer, db.ForeignKey("transactions.id"))

    address = orm.relationship(Address,
                               backref=orm.backref(
                                   "addresses", cascade="all, delete-orphan"))
    transaction = orm.relationship(Transaction,
                                   backref=orm.backref(
                                       "transactions",
                                       cascade="all, delete-orphan"))

    @property
    def hash(self):
        return self.transaction.hash
Пример #6
0
class Medicines(db.Model):
    """Medicines table"""
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(100), unique=True, nullable=False)
    dosage = db.Column(db.Integer, nullable=False)
    dosage_unit = db.Column(db.String, nullable=False)
    frequency = db.Column(db.String, nullable=False)
    frequency_unit = db.Column(db.String, nullable=False)
    user_id = db.Column(db.Integer, db.ForeignKey('users.id'), nullable=False)

    def __repr__(self):
        return self.name
Пример #7
0
class Task(db.Model):

    __tablename__ = 'tasks'

    id = db.Column(db.Integer, primary_key=True)
    uuid = db.Column(db.String(length=32), unique=True)
    title = db.Column(db.String(length=200))
    description = db.Column(db.Text())
    date = db.Column(db.Date)
    start_time = db.Column(db.TIMESTAMP)
    end_time = db.Column(db.TIMESTAMP)
    duration = db.Column(db.Integer())
    user_id = db.Column(db.Integer,
                        db.ForeignKey('users.id', ondelete="CASCADE"))

    user = db.relationship('User', backref=db.backref('tasks', lazy='dynamic'))

    @property
    def objects(self):
        return db_managers.TaskManager(self)

    def save(self):
        self.objects.save()
Пример #8
0
class UserRoles(db.Model, ModelMixin):
    id = Column(Integer(), primary_key=True)
    user_id = Column(Integer(), db.ForeignKey('user.id', ondelete='CASCADE'))
    role_id = Column(Integer(), db.ForeignKey('role.id', ondelete='CASCADE'))