Ejemplo n.º 1
0
class WatchlistItemTag(db.Model):
    __tablename__ = 'watchlist_tags'
    id = db.Column(db.Integer, primary_key=True)
    tag_content = db.Column(db.String(), nullable=False)
    ticker_id = db.Column(db.Integer,
                          db.ForeignKey('watchlist_item.id',
                                        ondelete="CASCADE"),
                          nullable=False)
    db.UniqueConstraint(ticker_id, tag_content)

    def __repr__(self):
        return f"WatchlistItemTag('{self.tag_content}', '{self.ticker_id}')"
Ejemplo n.º 2
0
class ExchangeRate(db.Model):
    __tablename__ = 'exchange_rates'
    id = db.Column(db.Integer, primary_key=True)
    from_currency = db.Column(db.String(), nullable=False)
    to_currency = db.Column(db.String(), nullable=False)
    rate = db.Column(db.String(), nullable=False)
    date_updated = db.Column(db.String(),
                             nullable=False,
                             default=str(datetime.today().date()))
    db.UniqueConstraint(from_currency, to_currency)

    def __repr__(self):
        return f"ExchangeRate('{self.from_currency}', '{self.to_currency}', '{self.rate}' ,'{self.date_updated}')"
Ejemplo n.º 3
0
class Set(db.Model):
    __tablename__ = 'sets'
    no = db.Column(db.String(255), primary_key=True, nullable=False)
    name = db.Column(db.Text(150), nullable=False)
    type = db.Column(db.String(255), nullable=False)
    category_id = db.Column(db.String(255), nullable=False)
    category = db.Column(db.String(255), nullable=False)
    image_url = db.Column(db.String(255))
    thumbnail_url = db.Column(db.String(255))
    weight = db.Column(db.Float())
    dim_x = db.Column(db.Float())
    dim_y = db.Column(db.Float())
    dim_z = db.Column(db.Float())
    year_released = db.Column(db.String(4))
    obsolete = db.Column(db.Boolean())
    complete = db.Column(db.Boolean(), nullable=False)
    extras = db.Column(db.Boolean(), nullable=False)
    children = db.relationship("Part")
    __table_args__ = (
        db.UniqueConstraint("no"),
    )

    def __init__(self, no, name, type, category_id, category, image_url, thumbnail_url, weight, dim_x, dim_y, dim_z, year_released, obsolete, complete, extras):
        self.no = no
        self.name = name
        self.type = type
        self.category_id = category_id
        self.category = category
        self.image_url = image_url
        self.thumbnail_url = thumbnail_url
        self.weight = weight
        self.dim_x = dim_x
        self.dim_y = dim_y
        self.dim_z = dim_z
        self.year_released = year_released
        self.obsolete = obsolete
        self.complete = complete
        self.extras = extras

    def __repr__(self):
        return self.no + ", " + \
               self.name + ", "

    # subclass JSONEncoder
    class SetEncoder(JSONEncoder):
        def default(self, o):
            return o.__dict__
Ejemplo n.º 4
0
class Part(db.Model):
    __tablename__ = 'parts'
    no = db.Column(db.String(255), primary_key=True, nullable=False)
    set_no = db.Column(db.String(255), db.ForeignKey('sets.no'), primary_key=True, nullable=False)
    color_id = db.Column(db.String(255), primary_key=True, nullable=False)
    color_name = db.Column(db.String(255), nullable=False)
    color_code = db.Column(db.String(255), nullable=False)
    color_type = db.Column(db.String(255), nullable=False)
    name = db.Column(db.Text(150), nullable=False)
    type = db.Column(db.String(255), nullable=False)
    category_id = db.Column(db.String(255), nullable=False)
    owned_quantity = db.Column(db.Integer())
    quantity = db.Column(db.Integer())
    extra_quantity = db.Column(db.Integer())
    is_alternate = db.Column(db.Boolean())
    is_counterpart = db.Column(db.Boolean())
    thumbnail_url = db.Column(db.String(255))
    __table_args__ = (
        db.UniqueConstraint("no", "set_no", "color_id"),
    )

    def __init__(self, no, set_no, name, type, category_id, color_id, color_name, color_code, color_type, owned_quantity, quantity, extra_quantity, is_alternate, is_counterpart, thumbnail_url):
        self.no = no
        self.set_no = set_no
        self.name = name
        self.type = type
        self.category_id = category_id
        self.color_id = color_id
        self.color_name = color_name
        self.color_code = color_code
        self.color_type = color_type
        self.owned_quantity = owned_quantity
        self.quantity = quantity
        self.extra_quantity = extra_quantity
        self.is_alternate = is_alternate
        self.is_counterpart = is_counterpart
        self.thumbnail_url = thumbnail_url

    def __repr__(self):
        return '<Part %r>' % self.no

    # subclass JSONEncoder
    class PartEncoder(JSONEncoder):
        def default(self, o):
            return o.__dict__
Ejemplo n.º 5
0
class WatchlistItem(db.Model):
    __tablename__ = 'watchlist_item'
    id = db.Column(db.Integer, primary_key=True)
    ticker_name = db.Column(db.String(), unique=False, nullable=False)
    notes = db.Column(db.String(), nullable=False, default='')
    sector = db.Column(db.String(), nullable=False)
    date_added = db.Column(db.DateTime,
                           nullable=False,
                           default=datetime.today())
    user_id = db.Column(db.Integer,
                        db.ForeignKey('user.id', ondelete="CASCADE"),
                        nullable=False)
    tags = db.relationship('WatchlistItemTag',
                           backref='item',
                           lazy=True,
                           cascade="all, delete, delete-orphan",
                           passive_deletes=True)
    db.UniqueConstraint(user_id, ticker_name)

    def __repr__(self):
        return f"WatchlistTicker('{self.ticker_name}', '{self.date_added})"