Exemple #1
0
class Addproduct(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(40), nullable=False)
    price = db.Column(db.Numeric(10, 2), nullable=False)
    discount = db.Column(db.Integer, default=0)
    stock = db.Column(db.Integer, nullable=False)
    color = db.Column(db.Text, nullable=False)
    desc = db.Column(db.Text, nullable=False)
    pub_date = db.Column(db.DateTime, nullable=False, default=datetime.utcnow)
    category_id = db.Column(db.Integer,
                            db.ForeignKey('category.id'),
                            nullable=False)
    category = db.relationship('Category',
                               backref=db.backref('categories', lazy=True))
    brand_id = db.Column(db.Integer, db.ForeignKey('brand.id'), nullable=False)
    brand = db.relationship('Brand', backref=db.backref('brands', lazy=True))
    image1 = db.Column(db.String(150), nullable=False, default='image1.jpg')
    image2 = db.Column(db.String(150), nullable=False, default='image2.jpg')
    image3 = db.Column(db.String(150), nullable=False, default='image3.jpg')
    merchant_id = db.Column(db.Integer,
                            db.ForeignKey('merchant.id'),
                            nullable=False)
    merchant = db.relationship('Merchant',
                               backref=db.backref('merchant', lazy=True))
    merchant_name = db.Column(db.String(45), nullable=False)
    merchant_phone = db.Column(db.String(45), nullable=False)
    merchant_address = db.Column(db.Text, nullable=False)

    def __repr__(self):
        return '<Addproduct %r>' % self.name
Exemple #2
0
class Product(db.Model):
    __tablename__ = 'product'
    product_id = db.Column(db.Integer(), primary_key=True)
    product_name = db.Column(db.String(50))

    #Relationships

    #FKs
    sub_category_id = db.Column(db.Integer,
                                db.ForeignKey('subcategory.sub_category_id'))
    brand_id = db.Column(db.Integer, db.ForeignKey('brand.brand_id'))
Exemple #3
0
class Cart(db.Model):
    __table_args__ = {'extend_existing': True}
    id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)
    productid = db.Column(db.Integer,
                          db.ForeignKey('product.productid'),
                          nullable=False,
                          primary_key=True)
    quantity = db.Column(db.Integer, nullable=False)

    def __repr__(self):
        return f"Cart('{self.id}', '{self.productid}', '{self.quantity}')"
Exemple #4
0
class Cart(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)
    User = db.relationship(User, backref=db.backref('users', lazy=True))
    product_id = db.Column(db.Integer,
                           db.ForeignKey('addproduct.id'),
                           nullable=False)
    Addproduct = db.relationship(Addproduct,
                                 backref=db.backref('products', lazy=True))
    color = db.Column(db.Text, nullable=False)
    quantity = db.Column(db.Integer, nullable=False)
Exemple #5
0
class Order(db.Model):
    __table_args__ = {'extend_existing': True}
    id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)
    productid = db.Column(db.Integer,
                          db.ForeignKey('product.productid'),
                          nullable=False,
                          primary_key=True)
    quantity = db.Column(db.Integer, nullable=False)
    ordered_date = db.Column(db.DateTime,
                             nullable=False,
                             default=datetime.utcnow)

    def __repr__(self):
        return f"Order('{self.id}', '{self.productid}', '{self.quantity}' , '{self.ordered_date}')"
Exemple #6
0
class Shipment(db.Model):
    Shipment_ID = db.Column(db.String(10), primary_key=True, nullable=False)
    Shipment_Note = db.Column(db.String(50))
    Delivery_ID = db.Column(db.String(8),
                            db.ForeignKey('delivery.Delivery_ID'),
                            nullable=False)
    delivery = db.relationship('Delivery',
                               backref=db.backref('delivery', lazy=True))
Exemple #7
0
class Cart(db.Model, UserMixin):
    id = db.Column(db.Integer, primary_key=True)
    product_id = db.Column(
        db.Integer, db.ForeignKey("Addproduct", on_delete=models.CASCADE))
    name = db.Column(db.String(80), unique=False, nullable=False)
    profile = db.Column(db.String(180),
                        unique=False,
                        nullable=False,
                        default='profile.jpg')

    def __repr__(self):
        return '<User %r>' % self.username
Exemple #8
0
class Delivery(db.Model):
    User_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)
    product_id = db.Column(db.Integer,
                           db.ForeignKey('addproduct.id'),
                           nullable=False)
    merchant_id = db.Column(db.Integer,
                            db.ForeignKey('merchant.id'),
                            nullable=False)
    color = db.Column(db.Text, nullable=False)
    quantity = db.Column(db.Integer, nullable=False)
    Delivery_ID = db.Column(db.String(8), primary_key=True, nullable=False)
    Delivery_Reg_Time = db.Column(db.DateTime,
                                  auto_now_add=True,
                                  nullable=False)
    Delivery_Est_Date = db.Column(db.Date, nullable=False)
    Delivery_Sender = db.Column(db.String(45),
                                db.ForeignKey('addproduct.merchant_name'),
                                nullable=False)
    Delivery_Sender_Phone = db.Column(
        db.String(8),
        db.ForeignKey('addproduct.merchant_phone'),
        nullable=False)
    From_Address = db.Column(db.String(255),
                             db.ForeignKey('addproduct.merchant_address'),
                             nullable=False)
    Delivery_Recipient = db.Column(db.String(45), nullable=False)
    Delivery_Recipient_Phone = db.Column(db.String(8), nullable=False)
    To_Address = db.Column(db.String(255), nullable=False)
    Status_Reason = db.Column(db.String(255), nullable=True)
Exemple #9
0
class Merchant(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    email = db.Column(db.String(120),
                      db.ForeignKey('user.email'),
                      nullable=False)