Esempio n. 1
0
class Category(db.Model):
    __tablename__ = "category"
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(30), nullable=False, unique=True)

    def __init__(self, name):
        self.name = name
Esempio n. 2
0
class User(UserMixin, db.Model):
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(15), unique=True, nullable=False)
    email = db.Column(db.String(120), unique=True, nullable=False)
    password_hash = db.Column(db.String(128))
    password = db.Column(db.String(60), nullable=False)
    university = db.Column(db.String(100), nullable=True)
    address_house = db.Column(db.String(50), nullable=False)
    address_street = db.Column(db.String(100), nullable=True)
    address_towncity = db.Column(db.String(50), nullable=True)
    address_postcode = db.Column(db.String(10), nullable=False)

    def __repr__(self):
        return f"User('{self.username}', '{self.email}')"

    @property
    def password(self):
        raise AttributeError('password is not a readable attribute')

    @password.setter
    def password(self, password):
        self.password_hash = generate_password_hash(password)

    def verify_password(self, password):
        return check_password_hash(self.password_hash, password)
Esempio n. 3
0
class Good(db.Model):
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    name = db.Column(db.String(80))
    quantity = db.Column(db.Integer)
    content = db.Column(db.String(512))
    type_name = db.Column(db.String(80), db.ForeignKey('good_type.name'))
    purchase_price = db.Column(db.Float)
    trade_price = db.Column(db.Float)
    retail_price = db.Column(db.Float)
    good_url = db.Column(db.String(512))
    warehouse_name = db.Column(db.String(80), db.ForeignKey('warehouse.name'))
    images = db.relationship('Image', backref='good', lazy='dynamic')

    def __init__(self, name, quantity, content, type_name, purchase_price, trade_price, retail_price,  good_url, warehouse_name):
        self.name = name
        self.quantity = quantity
        self.content = content
        self.type_name = type_name
        self.purchase_price = purchase_price
        self.trade_price = trade_price
        self.retail_price = retail_price
        self.good_url = good_url
        self.warehouse_name = warehouse_name

    def __repr__(self):
        return '<Good %s %d %s>' % (self.name, self.quantity, self.content)
Esempio n. 4
0
class FilterCategories(db.Model):
    """
    Which filters should show up for different category selections
    """
    id = db.Column(db.Integer, primary_key=True)
    filter_id = db.Column(db.Integer, db.ForeignKey("filters.id"))
    category_id = db.Column(db.Integer, db.ForeignKey("categories.id"))
Esempio n. 5
0
class User(db.Model):
    __tablename__: 'user'

    id = db.Column(db.Integer, primary_key=True)
    name = db.Text(db.Text)
    username = db.Column(db.Text, unique=True)
    email = db.Column(db.String(120), unique=True, nullable=False)
    password = db.Column(db.Text, nullable=False)
    profile = db.Column(db.String(180), default='profile.jpg')

    def __init__(self, name, email, username, password):
        self.name = name
        self.username = username
        self.email = email
        self.password = bcrypt.generate_password_hash(password).decode('UTF-8')

    @classmethod
    def authenticate(cls, username, password):
        found_user = cls.query.filter_by(username=username).first()
        if found_user:
            authenticated_user = bcrypt.check_password_hash(
                found_user.password, password)
            if authenticated_user:
                return found_user
        return False

    def __repr__(self):
        return '<User {}>'.format(self.name)
Esempio n. 6
0
class Manufacturer(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(30),nullable=False)
    phones = db.relationship('Phone', backref='manufacturer', lazy=True)

    def __repr__(self):
        return f"Manufacturer('{self.name}')"
Esempio n. 7
0
class Cart(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    quantity = db.Column(db.Integer)
    phone_id = db.Column(db.Integer, db.ForeignKey('phone.id'), nullable=False)

    def __repr__(self):
        return f"Cart('{self.quantity}')"
Esempio n. 8
0
class Category(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(30), unique=True, nullable=False)
    url = db.Column(db.String(20), unique=True)
    image_1 = db.Column(db.String(150),default='image1.jpg')
    def __repr__(self):
        return '<Catgory %r>' % self.name
Esempio n. 9
0
class Filter(db.Model):
    """
    e.g. style, color
    """
    __tablename__ = "filters"
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String)
Esempio n. 10
0
class CartDetails(db.Model):
    cartdetailsid = db.Column(db.Integer, primary_key=True)
    quantity = db.Column(db.Integer, nullable=False)
    cartid = db.Column(db.Integer,
                       db.ForeignKey('cart.cartid'),
                       nullable=False)
    itemid = db.Column(db.Integer,
                       db.ForeignKey('item.itemid'),
                       nullable=False)

    def __init__(self, itemid, quantity, cartid):
        # checking to see if Cart by cartid already exists
        cart = Cart.query.filter_by(cartid=cartid).first()

        # if not instantiate new Cart object
        if cart is None:
            cart = Cart()
            cartid = cart.cartid
        else:
            cartid = cart.cartid

        self.itemid = itemid
        self.quantity = quantity
        self.cartid = cartid

    def __repr__(self):
        return f"Item ID: '{self.itemid}'/n", \
               f"Quantity: '{self.quantity}'/n", \
               f"Cart ID: '{self.cartid}'/n"
Esempio n. 11
0
class Maker(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    Name = db.Column(db.String(20), nullable=False)
    items = db.relationship('Item', backref='maker', lazy=True)

    def __repr__(self):
        return f"Maker('{self.first_name}', '{self.last_name}')"
Esempio n. 12
0
class Author(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    first_name = db.Column(db.String(20),nullable=False)
    last_name = db.Column(db.String(30),nullable=False)
    books = db.relationship('Book', backref='author', lazy=True)

    def __repr__(self):
        return f"Author('{self.first_name}', '{self.last_name}')"
class Wishlist(db.Model):
    wishlist_user_id = db.Column(
        db.Integer, db.ForeignKey('user.id'), primary_key=True)
    wishlist_item_id = db.Column(
        db.Integer, db.ForeignKey('books.book_id'), primary_key=True)

    def __repr__(self):
        return f"Wishlist('{self.wishlist_user_id}', '{self.wishlist_item_id}')"
Esempio n. 14
0
class Producer(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    first_name = db.Column(db.String(20),nullable=False)
    last_name = db.Column(db.String(30),nullable=False)
    movie = db.relationship('Movie', backref='producer', lazy=True)

    def __repr__(self):
        return f"Producer('{self.first_name}', '{self.last_name}')"
Esempio n. 15
0
class Product(db.Model):
    __tablename__ = "products"

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String)
    inventory_quantity = db.Column(db.Integer)
    price = db.Column(db.Numeric(8, 2))
    weight = db.Column(db.Numeric(8, 2))
Esempio n. 16
0
class Admin(db.Model):
    name = db.Column(db.String(255), nullable=False)
    email = db.Column(db.String(120), unique=True, nullable=False)
    password = db.Column(db.String(180), unique=False, nullable=False)
    phno = db.Column(db.Integer, primary_key=True, nullable=False)

    def __repr__(self):
        return '<Admin %r>' % self.phno
Esempio n. 17
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)
Esempio n. 18
0
class Review(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    user_name = db.Column(db.String(120), nullable=False)
    body = db.Column(db.String(500), nullable=False)
    item_id = db.Column(db.Integer, db.ForeignKey('item.id'), nullable=False)

    def __repr__(self):
        return f"Review('{self.user_name}', '{self.body}')"
Esempio n. 19
0
class Customer(db.Model, UserMixin):
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(30), unique=True, nullable=False)
    email = db.Column(db.String(120), unique=True, nullable=False)
    password = db.Column(db.String(60), nullable=False)

    def __repr__(self):
        return "User('%s', '%s')" % (self.username, self.email)
Esempio n. 20
0
class Florist(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    first_name = db.Column(db.String(20), nullable=False)
    last_name = db.Column(db.String(30), nullable=False)
    flowers = db.relationship('Flower', backref='florist', lazy=True)

    def __repr__(self):
        return f"Florist('{self.first_name}', '{self.last_name}')"
Esempio n. 21
0
class Category(db.Model):
    __tablename__ = "categories"
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String, unique=True)

    products = db.relationship("Product",
                               secondary="product_categories",
                               backref=db.backref("categories"))
Esempio n. 22
0
class FilterOptions(db.Model):
    """
    e.g. large, red
    """
    __tablename__ = "filter_options"
    id = db.Column(db.Integer, primary_key=True)
    filter_id = db.Column(db.Integer, db.ForeignKey("filters.id"))
    name = db.Column(db.String)
Esempio n. 23
0
class ProductCategory(db.Model):
    __tablename__ = "product_categories"
    id = db.Column(db.Integer, primary_key=True)
    product_id = db.Column(db.Integer, db.ForeignKey("products.id"))
    category_id = db.Column(db.Integer, db.ForeignKey("categories.id"))

    product = db.relationship("Product",
                              backref=db.backref("product_categories"))
Esempio n. 24
0
class User(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = 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), nullable=False)

    def __repr__(self):
        return '<User %r>' % self.username
Esempio n. 25
0
class Brand(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(64), unique=True, nullable=False)

    def __repr__(self):
        return '<Brand %r>' % self.name

    def __str__(self):
        return '<Brand %r>' % self.name
Esempio n. 26
0
class AccountUser(db.Model, UserMixin):
    __tablename__ = "account_users"

    id = db.Column(db.Integer, primary_key=True)
    email = db.Column(db.String, unique=True)
    first_name = db.Column(db.String)
    last_name = db.Column(db.String)

    account_roles = db.relationship('AccountRole', secondary='roles_users')
Esempio n. 27
0
class User(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(20), unique=True, nullable=False)
    email = db.Column(db.String(120), unique=True, nullable=False)
    picture = db.Column(db.String(120), nullable=False, default='default.jpg')
    password = db.Column(db.String(), nullable=False)

    def __repr__(self):
        return f"User('{self.username}', '{self.email}', '{self.picture}')"
Esempio n. 28
0
class brands(db.Model):
    company = db.Column(db.String(255), nullable=False)
    model = db.Column(db.String(255), unique=True, nullable=False)
    modelno = db.Column(db.Integer, primary_key=True, nullable=False)
    image = db.Column(db.String(100), nullable=False)

    # fee = db.relationship('fee', backref = 'price')
    def __repr__(self):
        return '<Brand %r>' % self.modelno
Esempio n. 29
0
class Product(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    p_name = db.Column(db.String(100), nullable=False)
    description = db.Column(db.UnicodeText, nullable=False)
    image = db.Column(db.String(20), nullable=False, default='default.jpg')
    price = db.Column(db.Float, nullable=False)

    def __repr__(self):
        return f"Product('{self.p_name}','{self.description}','{self.price}','{self.image}')"
class Purchased_items(db.Model):
    purchase_id = db.Column(db.Integer, db.ForeignKey(
        'purchases.purchase_id'), primary_key=True)
    item_id = db.Column(db.Integer, db.ForeignKey(
        'books.book_id'), primary_key=True)
    quantity = db.Column(db.Integer, nullable=False)

    def __repr__(self):
        return f"Purchased_items('{self.purchase_id}', '{self.item_id}', '{self.quantity})"