Beispiel #1
0
class User(db.Model, UserMixin):
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(22), unique=True, nullable=False)
    email = db.Column(db.String(40), unique=True, nullable=False)
    password = db.Column(db.String(60), nullable=False)
    firstname = db.Column(db.String(30), nullable=True)
    lastname = db.Column(db.String(40), nullable=True)
    contact = db.Column(db.String(12), unique=True, nullable=True)
    alter_contact = db.Column(db.String(10), unique=True, nullable=True)
    role = db.Column(db.String(6), unique=False, nullable=False)
    verified = db.Column(db.String(3),
                         unique=False,
                         default='no',
                         nullable=False)
    date_register = db.Column(db.DateTime, unique=False, nullable=False)
    minimum_shippingfee = db.Column(db.String(10),
                                    unique=False,
                                    default='1000',
                                    nullable=True)
    product = db.relationship("Products", backref="owner_product")
    payment_due = db.relationship("PaymentDue", backref="owner_paymentdue")
    payment_recieve = db.relationship("PaymentRecieved",
                                      backref="owner_paymentrevieve")
    o_profile = db.relationship("Profile",
                                backref="owner_profile",
                                uselist=False)
    o_blog = db.relationship("Blog", backref="owner_blog")

    def __repr__(self):
        return "(username: %s)" % (self.username)
Beispiel #2
0
class Order(db.Model):
    __tablename__ = 'orders'

    id = db.Column(db.Integer, primary_key=True)
    date = db.Column(db.DateTime, nullable=False)
    summ = db.Column(db.Integer, nullable=False)
    status = db.Column(db.String, nullable=False)
    meals = db.relationship("Meal",
                            secondary=meals_orders_association,
                            back_populates="orders")
    user_id = db.Column(db.Integer, db.ForeignKey("users.id"))
    user = db.relationship("User", back_populates="orders")
Beispiel #3
0
class Meal(db.Model):
    __tablename__ = 'meals'

    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String(), nullable=False)
    price = db.Column(db.Integer, nullable=False)
    description = db.Column(db.String(), nullable=False)
    picture = db.Column(db.String(), nullable=False)
    category_id = db.Column(db.Integer, db.ForeignKey("categories.id"))
    category = db.relationship("Category", back_populates="meals")
    orders = db.relationship("Order",
                             secondary=meals_orders_association,
                             back_populates="meals")
Beispiel #4
0
class Cookie(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    cook_id = db.Column(db.String(50), nullable=False)
    cart = db.relationship("Cart", backref='cartowner', uselist=False)

    def __repr__(self):
        return "(cookie: %s)" % (self.cook_id)
Beispiel #5
0
class Products(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    date_add = db.Column(db.DateTime, unique=False, nullable=False)
    productcode = db.Column(db.String(50), unique=True, nullable=False)
    title = db.Column(db.String(35), unique=False, nullable=False)
    price = db.Column(db.String(7), unique=False, nullable=False)
    shipping_fee = db.Column(db.String(5), unique=False, nullable=False)
    promotion = db.Column(db.String(6), unique=False, nullable=True, default=0)
    promotion_expire = db.Column(db.DateTime, unique=False, nullable=True)
    imgfile1 = db.Column(db.String(50), unique=True, nullable=False)
    imgfile2 = db.Column(db.String(50), unique=True, nullable=True)
    imgfile3 = db.Column(db.String(50), unique=True, nullable=True)
    imgfile4 = db.Column(db.String(50), unique=True, nullable=True)
    quantity = db.Column(db.Integer, unique=False, nullable=False, default=0)
    category = db.Column(db.String(20),
                         unique=False,
                         nullable=False,
                         default='Category')
    tag = db.Column(db.String(50), unique=False, nullable=True, default='tag')
    description = db.Column(db.Text, nullable=True)
    view = db.Column(db.Integer, unique=False, nullable=False, default=0)
    number_bought = db.Column(db.Integer,
                              unique=False,
                              nullable=False,
                              default=0)
    owner_id = db.Column(db.Integer, db.ForeignKey('user.id'))
    review = db.relationship("Reviews", backref='product_review')

    def __repr__(self):
        return "(title: %s)" % (self.title)
Beispiel #6
0
class Checkout(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    contact = db.Column(db.String(20), unique=False, nullable=False)
    reference = db.Column(db.String(10), unique=True, nullable=False)
    confirm_address = db.Column(db.String(20), unique=False, default='n')
    payment = db.Column(db.String(20), unique=False, default='n')
    payment_expire = db.Column(db.DateTime, nullable=True)
    payment_complete = db.Column(db.DateTime, nullable=True)
    totalprice = db.Column(db.String(20), unique=False, nullable=True)
    items = db.relationship("CheckoutItems", backref='Checkout')
    shippingaddress = db.relationship("ShipAddress",
                                      backref='CheckoutAddress',
                                      uselist=False)

    def __repr__(self):
        return "(Name: {})".format(self.contact)
Beispiel #7
0
class User(db.Model):
    __tablename__ = 'users'

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(32), nullable=False)
    mail = db.Column(db.String(55), nullable=False, unique=True)
    password_hash = db.Column(db.String(128), nullable=False)
    address = db.Column(db.String(100))
    orders = db.relationship("Order", back_populates="user")
Beispiel #8
0
class Cart(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    cartcode = db.Column(db.String(50), unique=True, nullable=False)
    date_create = db.Column(db.DateTime, nullable=False)
    date_expire = db.Column(db.DateTime, nullable=False)
    owner = db.Column(db.Integer, db.ForeignKey('cookie.id'))
    items = db.relationship("CartItems", backref='cart')

    def __repr__(self):
        return "(CartCode: %s)" % (self.cartcode)
Beispiel #9
0
class Category(db.Model):
    __tablename__ = 'categories'

    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String(32), nullable=False)
    meals = db.relationship("Meal", back_populates="category")