コード例 #1
0
class Person(Base):
    __tablename__ = 'people'
    id = db.Column(db.Integer, primary_key=True)
    first_name = db.Column(db.String(50))
    middle_name  = db.Column(db.String(50),nullable=True)  
    last_name = db.Column(db.String(50))
    email_address  = db.Column(db.String(50))  
    phone_number = db.Column(db.String(20))
    gender  = db.Column('gender', Enum(GenderType))
    date_of_birth = db.Column(db.DateTime(), default=datetime.now())
コード例 #2
0
class Brand(Base):
    __tablename__ = 'brands'

    name  = db.Column(db.String(50), unique=True, nullable=False)
    slug =  db.Column(db.String(50), unique=True, nullable=False)
    description  = db.Column(db.Text())
    meta_description  = db.Column(db.String(500))
    meta_keywords  = db.Column(db.String(500))
    brand_status  = db.Column('brand_status', Enum(StatusType))

    def __repr__(self):
        return self.name
コード例 #3
0
class Product(Base):
    __tablename__ = 'products'

    name  = db.Column(db.String(50), unique=True, nullable=False)
    slug =  db.Column(db.String(50), unique=True, nullable=False)
    description  = db.Column(db.Text())
    meta_description  = db.Column(db.String(500))
    meta_keywords  = db.Column(db.String(500))
    sku = db.Column(db.String(100))
    model = db.Column(db.String(200))
    price = db.Column(db.Float())
    old_price = db.Column(db.Float())
    image_url = db.Column(db.String(250))
    is_bestseller = db.Column(db.Boolean())     
    is_featured = db.Column(db.Boolean())    
    quantity = db.Column(db.Integer())
    categories = db.relationship('Category',secondary=product_category,lazy='subquery')
    brands = db.relationship('Brand',secondary=product_brand,lazy='subquery')
    product_status  = db.Column('product_status', Enum(StatusType))
    
    def sale_price(self):           
        if self.old_price > self.price:                
            return self.price           
        else:                
            return None

    def __repr__(self):
        return self.name
コード例 #4
0
ファイル: models.py プロジェクト: linnzacharias/bmes
class Address(Base):
    __tablename__ = 'addresses'
    name = db.Column(db.String(50), nullable=True)
    address_line_1 = db.Column(db.String(150))
    address_line_2 = db.Column(db.String(150), nullable=True)
    city = db.Column(db.String(50))
    state = db.Column(db.String(50))
    country = db.Column(db.String(50))
    zip_code = db.Column(db.String(50))
    address_type = db.Column('address_type', Enum(AddressType))
コード例 #5
0
class Cart(Base):
    __tablename__ = 'carts'
    unique_cart_id = db.Column(db.String(500), unique=False)
    cart_items = db.relationship('CartItem', backref='cart_items', lazy=True)
    cart_status = db.Column('cart_status', Enum(CartStatus))