class Item(Base): __tablename__ = 'items' product_id = db.Column( UUID, db.ForeignKey('products.id'), nullable=False) product = db.relationship( 'Product', backref=db.backref('items')) cart_id = db.Column( UUID, db.ForeignKey('carts.id'), nullable=False) cart = db.relationship( 'Cart', backref=db.backref('items')) quantity = db.Column(db.Integer) price = db.Column(db.Float(precision=2), nullable=False) serializable = [ 'id', 'product_id', 'cart_id', 'quantity', 'price', 'created_at', 'modified_at' ] def serialize(self): rv = super(Member, self).serialize() return rv
class Cart(Base): __tablename__ = 'carts' account_id = db.Column(UUID, db.ForeignKey('accounts.id'), nullable=False) account = db.relationship('Account', backref=db.backref('carts')) active = db.Column(db.Boolean, default=True) serializable = ['id'] def serialize(self): rv = super(Subscription, self).serialize() return rv
class ProductSubcategory(Base): __tablename__ = 'product_subcategories' product_category_id = db.Column(UUID, db.ForeignKey('product_categories.id'), nullable=False) product_category = db.relationship( 'ProductCategory', backref=db.backref('product_subcategories')) name = db.Column(db.String(80), nullable=False) description = db.Column(db.String(80), nullable=True) serializable = ['id', 'product_category_id', 'name', 'description'] def serialize(self): rv = super(Subscription, self).serialize() return rv
class Product(Base): __tablename__ = 'products' product_subcategory_id = db.Column( UUID, db.ForeignKey('product_subcategories.id'), nullable=False) product_subcategory = db.relationship('ProductSubcategory', backref=db.backref('products')) name = db.Column(db.String(20), nullable=False) description = db.Column(db.Text(), nullable=True) price = db.Column(db.Float(precision=2), nullable=False) available_item_count = db.Column(db.Integer) image = db.Column(db.String(20), nullable=False) serializable = [ 'id', 'product_subcategory_id', 'name', 'description', 'price', 'available_item_count', 'created_at', 'modified_at' ] def serialize(self): rv = super(Member, self).serialize() return rv
class Member(Base): __tablename__ = 'subscription_members' subscription_id = db.Column(UUID, db.ForeignKey('subscriptions.id'), nullable=False) subscription = db.relationship('Subscription', backref=db.backref('members')) name = db.Column(db.String(80), nullable=False) mobile = db.Column(db.String(20), index=True) email = db.Column(db.String(50)) age = db.Column(db.Integer) gender = db.Column(db.Enum(Gender)) serializable = [ 'id', 'subscription_id', 'name', 'mobile', 'email', 'age', 'gender', 'created_at', 'modified_at' ] def serialize(self): rv = super(Member, self).serialize() return rv