コード例 #1
0
class payment(db.Model):
    id = db.Column(db.Integer(), primary_key=True)
    total_price = db.Column(db.Integer())
    user_cart = db.Column(db.String(25), db.ForeignKey('user.username'))
    address = db.Column(db.String(100), nullable=False)
    card_no = db.Column(db.String(16), nullable=False)
    card_exp_date = db.Column(db.String(5), nullable=False)
    name_on_card = db.Column(db.String(20), nullable=False)

    def __repr__(self):
        return f"payment('{self.total_price}', '{self.name_on_card}')"
コード例 #2
0
class Admin(db.Model, UserMixin):
    id = db.Column(db.Integer(), primary_key=True)
    username = db.Column(db.String(255), nullable=False, unique=True)
    email = db.Column(db.String(80), nullable=False, unique=True)
    password = db.Column(db.Text(), nullable=False)

    def __repr__(self):
        return "user {}".format(self.username)
コード例 #3
0
class Seller(db.Model, UserMixin):
    id = db.Column(db.Integer(), primary_key=True)
    username = db.Column(db.String(255), nullable=False, unique=True)
    email = db.Column(db.String(80), nullable=False, unique=True)
    password = db.Column(db.Text(), nullable=False)
    comm_type = db.Column(db.String(25), nullable=False)
    products = db.relationship("Product", backref="seller", lazy=True)

    def __repr__(self):
        return "seller {}".format(self.username)
コード例 #4
0
class Supplier(db.Model):
    id = db.Column(db.Integer(), primary_key=True)
    name = db.Column(db.String(80), nullable=False, unique=True)
    email = db.Column(db.String(80), nullable=False, unique=True)
    phone_contact = db.Column(db.Text(10), nullable=False)
    location = db.Column(db.String(80), nullable=False, unique=True)
    type = db.Column(db.String(80), nullable=False)
    products = db.relationship("Product", backref="supplier", lazy=True)

    def __repr__(self):
        return "supplier {}".format(self.name)
コード例 #5
0
class Product(db.Model):
    product_id = db.Column(db.Integer(), primary_key=True)
    prod_name = db.Column(db.String(255), nullable=False, unique=True)
    selling_price = db.Column(db.Integer(), nullable=False)
    cost_price = db.Column(db.Integer(), nullable=False)
    discount = db.Column(db.Integer(), nullable=False)
    stock = db.Column(db.Integer(), nullable=False)
    prod_type = db.Column(db.String(80), nullable=False)
    seller_id = db.Column(db.Integer(), db.ForeignKey('seller.id'))
    supplier_id = db.Column(db.Integer(), db.ForeignKey('supplier.id'))

    def __repr__(self):
        return "product {}".format(self.prod_name)
コード例 #6
0
ファイル: models.py プロジェクト: Marwos97/efiprog2
class Addskin(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(80), nullable=False)
    price = db.Column(db.DECIMAL(10, 0), nullable=False)
    float = db.Column(db.DECIMAL(10, 0), nullable=False)
    stock = db.Column(db.Integer(), default=1)

    brand_id = db.Column(db.Integer, db.ForeignKey('brand.id'), nullable=False)
    brand = db.relationship('Brand', backref=db.backref('brands', lazy=True))

    category_id = db.Column(db.Integer,
                            db.ForeignKey('category.id'),
                            nullable=False)
    category = db.relationship('Category',
                               backref=db.backref('posts', lazy=True))

    image = db.Column(db.String(150), nullable=False, default='image.jpg')

    def __repr__(self):
        return '<Post %r>' % self.title

    @staticmethod
    def get_by_collection(category_id):
        return Addskin.query.filter_by(category_id=category_id).first()
コード例 #7
0
class Review(db.Model):
    id = db.Column(db.Integer(), primary_key=True)
    item_id = db.Column(db.Integer, db.ForeignKey('movie.id'), nullable= False)
    username=db.Column(db.String(15), db.ForeignKey('user.username'), nullable=False)
    review=db.Column(db.String(60), nullable=False)