Exemplo n.º 1
0
class User(db.Model, UserMixin):
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(20), unique=True, nullable=False)
    email = db.Column(db.String(20), unique=True, nullable=False)
    password = db.Column(db.String(20), nullable=False)

    def __repr__(self):
        return f"User('{self.username}', '{self.email}', '{self.password}')"
Exemplo n.º 2
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))
Exemplo n.º 3
0
class User(db.Model, UserMixin):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(80), unique=False, nullable=False)
    username = db.Column(db.String(80), unique=True, nullable=False)
    email = db.Column(db.String(120), unique=True, nullable=False)
    password = db.Column(db.String(120), unique=False, nullable=False)

    def __repr__(self):
        return '<User %r>' % self.username
Exemplo n.º 4
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
Exemplo n.º 5
0
class Product(db.Model):
    __table_args__ = {'extend_existing': True}
    productid = db.Column(db.Integer, primary_key=True)
    product_name = db.Column(db.String(100), nullable=False)
    image = db.Column(db.String(100), nullable=False)
    quantity = db.Column(db.Integer, nullable=False)
    regular_price = db.Column(db.DECIMAL(10, 2))
    discounted_price = db.Column(db.DECIMAL(10, 2))
    product_rating = db.Column(db.DECIMAL(2, 1))

    def __repr__(self):
        return f"Product('{self.productid}','{self.product_name}','{self.description}', '{self.image}',  '{self.quantity}', '{self.regular_price}', '{self.discounted_price}')"
Exemplo n.º 6
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)
Exemplo n.º 7
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'))
Exemplo n.º 8
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
Exemplo n.º 9
0
class Brand(db.Model):
    __tablename__ = 'brand'
    brand_id = db.Column(db.Integer(), primary_key=True)
    brand_name = db.Column(db.String(50))

    # Relationships
    product = db.relationship('Product', backref='brand', lazy='joined',
                              cascade='all,delete')

    # FKs

    def __repr__(self):
        return f"Brand({self.brand_name})"
Exemplo n.º 10
0
class Category(db.Model):
    __tablename__ = 'category'
    category_id = db.Column('category_id', db.Integer(), primary_key=True)
    category_name = db.Column('category_name', db.String(50))

    #Relationships
    subcategory = db.relationship('SubCategory',
                                  backref='category',
                                  lazy='joined',
                                  cascade="all,delete")

    #FKs

    def __repr__(self):
        return f"Cat({self.category_id},{self.category_name})"
Exemplo n.º 11
0
class Category(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(30), nullable=False, unique=True)
Exemplo n.º 12
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)