Exemplo n.º 1
0
class Variantoptions(Base):
    __category__ = 'Product'

    available_for_sale = db.Column(db.Boolean, default=False)
    currently_not_in_stock = db.Column(db.Boolean)
    requires_shipping = db.Column(db.Boolean)
    quantity_available = db.Column(db.Integer)
    compare_at_price = db.Column(db.Float)
    unit_price = db.Column(db.Float)
    weight = db.Column(db.Float)
    price = db.Column(db.Float)
    namespace = db.Column(db.String)
    title = db.Column(db.String)
    sku = db.Column(db.String)
    key = db.Column(db.String)
    selected_options = db.relationship('Option',
                                       secondary=variants_options_relation,
                                       backref=db.backref('variantoptions',
                                                          lazy='dynamic'))
    images = db.relationship('Image',
                             secondary=images_options_relation,
                             backref=db.backref('variantoptions',
                                                lazy='dynamic'))
    metafield = db.relationship('Metafield',
                                backref='variant_options',
                                lazy=True,
                                uselist=True)
    product = db.Column(db.Integer, db.ForeignKey('product.id'))
Exemplo n.º 2
0
class ItemModel(db.Model):
    __tablename__ = 'items'

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(80))
    price = db.Column(db.Float(precision=2))

    store_id = db.Column(db.Integer, db.ForeignKey('stores.id'))
    store = db.relationship('StoreModel')

    def __init__(self, name, price, store_id):
        self.name = name
        self.price = price
        self.store_id = store_id

    def json(self):
        return {
            'id': self.id,
            'name': self.name,
            'price': self.price,
            'store_id': self.store_id
        }

    @classmethod
    def find_by_name(cls, name):
        return cls.query.filter_by(name=name).first()

    @classmethod
    def find_all(cls):
        return cls.query.all()

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

    def delete_from_db(self):
        db.session.delete(self)
        db.session.commit()
Exemplo n.º 3
0
from store.extensions import db

metafield_self_relation = db.Table(
    'metafield_relation',
    db.Column('my_id', db.Integer, db.ForeignKey('metafield.id')),
    db.Column('my_parent_id', db.Integer, db.ForeignKey('metafield.id')))

options_products_relation = db.Table(
    'options_products',
    db.Column('product_id', db.Integer(), db.ForeignKey('product.id')),
    db.Column('option_id', db.Integer(), db.ForeignKey('option.id')))

tags_products_relation = db.Table(
    'tags_products',
    db.Column('product_id', db.Integer(), db.ForeignKey('product.id')),
    db.Column('tag_id', db.Integer(), db.ForeignKey('tag.id')))

selected_options_products_relation = db.Table(
    'selectedinput_products',
    db.Column('product_id', db.Integer(), db.ForeignKey('product.id')),
    db.Column('selectedinput_id', db.Integer(),
              db.ForeignKey('selectedinput.id')))

images_options_relation = db.Table(
    'images_options',
    db.Column('variantoptinos_id', db.Integer(),
              db.ForeignKey('variantoptions.id')),
    db.Column('image_id', db.Integer(), db.ForeignKey('image.id')))

variants_options_relation = db.Table(
    'variant_options',
Exemplo n.º 4
0
class Pricerange(Base):
    __category__ = 'Product'

    max_variant_price = db.Column(db.Float)
    min_variant_price = db.Column(db.Float)
    product = db.Column(db.Integer, db.ForeignKey('product.id'))
Exemplo n.º 5
0
from store.extensions import db

shops_shipcountries_relation = db.Table(
    'countries_shops',
    db.Column('shop_id', db.Integer(), db.ForeignKey('shop.id')),
    db.Column('country_id', db.Integer(), db.ForeignKey('country.id')))
Exemplo n.º 6
0
from store.extensions import db

friend_relation = db.Table(
    'friend_relation', db.Column('my_id', db.Integer,
                                 db.ForeignKey('user.id')),
    db.Column('my_friends_id', db.Integer, db.ForeignKey('user.id')))
best_fried_relation = db.Table(
    'best_fried_relation',
    db.Column('my_id', db.Integer, db.ForeignKey('user.id')),
    db.Column('my_friends_id', db.Integer, db.ForeignKey('user.id')))

roles_users_relation = db.Table(
    'roles_users', db.Column('user_id', db.Integer(),
                             db.ForeignKey('user.id')),
    db.Column('role_id', db.Integer(), db.ForeignKey('role.id')))