Exemple #1
0
class OrderLine(db.Model):
    id = db.Column(db.Integer, primary_key=True)

    order_id = db.Column(db.Integer, db.ForeignKey('orders.id'))
    order = db.relationship("Order", backref=db.backref('orderlines', order_by=id)) 
        
    productvariant_id = db.Column(db.Integer, db.ForeignKey('productvariants.id'),nullable=True)
    productvariant =  db.relationship("ProductVariant")
        
    quantity = db.Column(db.Integer)
    unit_price = db.Column(db.Integer)    
    extradata = db.Column(db.String(1024), nullable=False)
                         
class CartLine(db.Model):
    __tablename__ = 'cartlines'

    id = db.Column(db.Integer, primary_key=True)
    productvariant_id = db.Column(db.Integer,
                                  db.ForeignKey('productvariants.id'))
    productvariant = db.relationship("ProductVariant")

    quantity = db.Column(db.Integer)
    data = db.Column(db.String(2048), nullable=False)

    cart_id = db.Column(db.Integer, db.ForeignKey('carts.id'))
    cart = db.relationship("Cart",
                           backref=db.backref('cartlines', order_by=id))
Exemple #3
0
class ProductVariant(db.Model):
    __tablename__ = "productvariants"
    
    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String(512), nullable=False)
    description = db.Column(db.Text)
    sku = db.Column(db.String(512))
    price = db.Column(db.Integer)
    inventory = db.Column(db.Integer)

    mainproduct_id = db.Column(db.Integer, db.ForeignKey('products.id'))
    mainproduct = db.relationship("Product", backref=db.backref('variants', order_by=id))

    def __repr__(self):
        return '<ProductVariant {!r}>'.format(self.title)