Пример #1
0
class Client(db.Model):
    """Client name, contact details, and address"""

    __tablename__ = 'clients'

    id = db.Column(db.Integer(), primary_key=True)
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)
    fname = db.Column(db.String(75))
    lname = db.Column(db.String(75))
    email = db.Column(db.String(100))
    phone = db.Column(db.String(75))
    address1 = db.Column(db.String(100))
    address2 = db.Column(db.String(100))
    city = db.Column(db.String(100))
    state = db.Column(db.String(50))
    zip_code = db.Column(db.Integer())

    def as_dict(self):
        return {c.name: getattr(self, c.name) for c in self.__table__.columns}
Пример #2
0
class Category(db.Model):
    """Item Category model"""

    __tablename__ = 'categories'

    id = db.Column(db.Integer(), primary_key=True)
    name = db.Column(db.String(255), nullable=False)
    parent_id = db.Column(db.Integer, db.ForeignKey('categories.id'))
    description = db.Column(db.Text)
    children = db.relationship('Category',
                               backref=db.backref('parent', remote_side=id))
Пример #3
0
class Product(db.Model):
    """Product model"""

    __tablename__ = 'products'

    id = db.Column(db.Integer(), primary_key=True)
    category_id = db.Column(db.Integer, db.ForeignKey('categories.id'))
    category = db.relationship('Category')
    circulation_id = db.Column(db.Integer, db.ForeignKey('circulation.id'))
    circulation = db.relationship('Circulation')
    duration_id = db.Column(db.Integer, db.ForeignKey('duration.id'))
    duration = db.relationship('Duration')
    image_size_id = db.Column(db.Integer, db.ForeignKey('image_size.id'))
    image_size = db.relationship('ImageSize')
    image_location_id = db.Column(db.Integer,
                                  db.ForeignKey('image_location.id'))
    image_location = db.relationship('ImageLocation')
    price = db.Column(db.Numeric(8, 2), nullable=False)
Пример #4
0
class ImageLocation(db.Model):
    """License image location"""

    id = db.Column(db.Integer(), primary_key=True)
    name = db.Column(db.String(255))
Пример #5
0
class ImageSize(db.Model):
    """License image size"""

    id = db.Column(db.Integer(), primary_key=True)
    name = db.Column(db.String(255))
Пример #6
0
class Circulation(db.Model):
    """License circulation model"""

    id = db.Column(db.Integer(), primary_key=True)
    name = db.Column(db.String(255))
Пример #7
0
class Role(db.Model, RoleMixin):
    """User roles"""

    id = db.Column(db.Integer(), primary_key=True)
    name = db.Column(db.String(80), unique=True)
    description = db.Column(db.String(255))
Пример #8
0
# -*- coding: utf-8 -*-
"""User models"""
from flask_security import UserMixin, RoleMixin
from quote.extensions import db

roles_users = db.Table(
    'roles_users', db.Column('user_id', db.Integer(),
                             db.ForeignKey('user.id')),
    db.Column('role_id', db.Integer(), db.ForeignKey('role.id')))


class Role(db.Model, RoleMixin):
    """User roles"""

    id = db.Column(db.Integer(), primary_key=True)
    name = db.Column(db.String(80), unique=True)
    description = db.Column(db.String(255))


class User(db.Model, UserMixin):
    """A user for the app"""

    id = db.Column(db.Integer, primary_key=True)
    email = db.Column(db.String(255), unique=True)
    business_name = db.Column(db.String(255), nullable=True)
    fname = db.Column(db.String(255), nullable=True)
    lname = db.Column(db.String(255), nullable=True)
    phone = db.Column(db.String(30), nullable=True)
    initial_setup = db.Column(db.Boolean)
    password = db.Column(db.String(255))
    active = db.Column(db.Boolean())