示例#1
0
class LandingPage(Model):
    __tablename__ = 'landing_pages'

    title = Column(String)
    slug = Column(String)
    meta_keyword = Column(String)
    meta_description = Column(String)
    meta_title = Column(String)
    h1 = Column(String)
    content = Column(String)
    country_id = Column(UUIDType(binary=False), ForeignKey('countries.id'))
    country = relationship('Country')
    language_id = Column(UUIDType(binary=False), ForeignKey('languages.id'))
    language = relationship('Language')
    status = Column(default_statuses)
    tags = relationship('Tag', secondary='landing_tags', backref='tags')
    # products = relationship('Product', secondary='product_landing_priority', backref='landing_pages')
    products = relationship("Product", secondary="product_landing_priority")

    def __repr__(self):
        return f'LandingPage: {self.id}'

    @hybrid_property
    def image(self):
        return Media.query.filter_by(entity_id=str(self.id)).first()
示例#2
0
class HomeBox(Model):
    __tablename__ = 'home_boxes'

    name = Column(JSONB)
    status = Column(ENUM('active', 'inactive', name='box_status'))
    tags = relationship('Tag', secondary='home_box_tags', backref='home_tags')
    landings = relationship('LandingPage',
                            secondary='home_box_landings',
                            backref='home_landings')

    def __repr__(self):
        return f'HomeBox: {self.id}'
示例#3
0
class Driver(Model):
    __tablename__ = 'drivers'
    username = Column(String, unique=True)
    phone_number = Column(String, unique=True)
    first_name = Column(String, nullable=False)
    last_name = Column(String, nullable=False)
    email = Column(EmailType, nullable=False)
    verified = Column(Boolean, default=False)
    type_id = Column(UUIDType(binary=False), ForeignKey('driver_types.id'))
    documents = relationship('DriverDocument')
    type = relationship('DriverType')

    def __repr__(self):
        return f'Driver: {self.id}'
示例#4
0
class Customer(UserMixin, Model):
    __tablename__ = "customer"
    username = Column(String, unique=True)
    first_name = Column(String(30))
    last_name = Column(String(50))
    email = Column(String(50), unique=True, nullable=False)
    profile_image = Column(String)
    gender = Column(Boolean, default=0)
    verified = Column(Boolean, default=False)
    is_active = Column(Boolean, default=False)
    password = Column(String(128))
    address = relationship('CustomerAddress')
    phone_number = Column(String)

    def set_password(self, password):
        self.password = generate_password_hash(password)

    def check_password(self, password):
        return check_password_hash(self.password, password)

    @hybrid_property
    def avatar(self):
        return 'uploads/customers/{}'.format(self.profile_image)

    def __repr__(self):
        return f'Customer: {self.id}'
示例#5
0
class ProductLandingPriority(Model):
    __tablename__ = 'product_landing_priority'

    product_id = Column(UUIDType(binary=False),
                        ForeignKey('products.id'),
                        nullable=False)
    landing_id = Column(UUIDType(binary=False),
                        ForeignKey('landing_pages.id'),
                        nullable=False)
    count = Column(Integer, default=0)
    landing = relationship(LandingPage,
                           backref=backref("product_landing_priority",
                                           cascade="all, delete-orphan"))
    product = relationship(Product,
                           backref=backref("products",
                                           cascade="all, delete-orphan"))
示例#6
0
class Attribute(Model):
    __tablename__ = 'attributes'

    name = Column(JSONB)
    description = Column(JSONB)
    status = Column(ENUM('active', 'inactive', name='attribute_status'))
    values = relationship('AttributeValue')
示例#7
0
class HelpCategory(Model):
    __tablename__ = 'help_categories'

    name = Column(JSONB)
    status = Column(ENUM('active', 'inactive', name='help_category_status'))
    articles = relationship('HelpArticle', backref='category')

    def __repr__(self):
        return f'HelpCategory: {self.id}'
示例#8
0
class Category(Model):
    __tablename__ = 'categories'

    name = Column(JSONB)
    parent_id = Column(UUIDType(binary=False),
                       ForeignKey('categories.id'),
                       nullable=True)
    description = Column(JSONB)
    meta_description = Column(String)
    meta_keyword = Column(String)
    top = Column(Boolean, default=False)
    sort_order = Column(Integer, default=0)
    status = Column(default_statuses)
    tags = relationship('Tag', secondary='category_tags', backref='category')
    parent = relationship("Category", remote_side=[parent_id])

    def __repr__(self):
        return f'Category: {self.id}'
示例#9
0
class DriverDocument(Model):
    __tablename__ = 'driver_documents'
    driver_id = Column(UUIDType(binary=False),
                       ForeignKey('drivers.id'),
                       nullable=False)
    document_type = Column(driver_document_types, nullable=False)
    verified = Column(Boolean, nullable=False)
    media_id = Column(UUIDType(binary=False), ForeignKey('media.id'))
    media = relationship('Media')

    def __repr__(self):
        return f'DriverDocument: {self.id}'
示例#10
0
class CarModel(Model):
    __tablename__ = "car_models"

    name = Column(String)
    make_id = Column(UUIDType(binary=False),
                     ForeignKey('car_makes.id'),
                     nullable=False)
    make_key = Column(String)
    trims = relationship('CarTrim')

    def __repr__(self):
        return f'CarModel: {self.id}'
示例#11
0
class ProductAttribute(Model):
    __tablename__ = 'product_attributes'

    product_id = Column(UUIDType(binary=False),
                        ForeignKey('products.id'),
                        nullable=False)
    attribute_id = Column(UUIDType(binary=False),
                          ForeignKey('attributes.id'),
                          nullable=False)
    values = relationship('AttributeValue',
                          secondary='product_attribute_values',
                          backref='products')
示例#12
0
class ProductCountry(Model):
    __tablename__ = 'product_countries'

    product_id = Column(UUIDType(binary=False),
                        ForeignKey('products.id'),
                        nullable=False)
    country_id = Column(UUIDType(binary=False),
                        ForeignKey('countries.id'),
                        nullable=False)
    country_code = Column(String)
    details = relationship('ProductDetail')

    def __repr__(self):
        return f'ProductCountry {self.id}'
示例#13
0
class Product(Model):
    __tablename__ = 'products'

    product_type_id = Column(UUIDType(binary=False),
                             ForeignKey('product_types.id'),
                             nullable=True)
    sku = Column(String)
    view_count = Column(Integer, default=0)
    tags = relationship('Tag', secondary='product_tags', backref='products')
    attribute_values = relationship('ProductAttribute', backref='products')
    image = relationship('ProductMedia', uselist=True)
    courier = relationship('ProductCourier', uselist=True)
    details = relationship('ProductDetail', uselist=True)

    @hybrid_property
    def detail(self):
        return ProductDetail.query.filter_by(product_id=str(self.id)).first()

    @hybrid_property
    def media(self):
        return ProductMedia.query.filter_by(product_id=str(self.id)).first()

    def __repr__(self):
        return f'Product: {self.id}'
示例#14
0
class Store(Model):
    __tablename__ = 'stores'

    company_name = Column(String, nullable=False)
    username = Column(String, unique=True)
    email = Column(String, unique=True, nullable=False)
    country = Column(String)
    address = Column(String)
    address_ltd = Column(String)
    address_details = Column(String)
    address_lng = Column(String)
    about = Column(String)
    delivery_area = Column(String)
    password = Column(PasswordType(schemes=['pbkdf2_sha512']), nullable=False)
    status = Column(ENUM('active', 'inactive', name='store_status'))
    phones = relationship(
        'CustomerPhone',
        primaryjoin="remote(Store.id)==foreign(CustomerPhone.entity_id)",
        uselist=True)

    def __repr__(self):
        return f'Store: {self.id}'
示例#15
0
class Receiver(Model):
    __tablename__ = 'receivers'

    full_name = Column(String)
    order_id = Column(UUIDType(binary=False),
                      ForeignKey('order.id'),
                      nullable=True)
    customer_id = Column(UUIDType(binary=False),
                         ForeignKey('customer.id'),
                         nullable=True)
    session_id = Column(String, nullable=True)

    # full_address = Column(String)
    # address_details = Column(String)
    # lat = Column(String)
    # lng = Column(String)
    phones = relationship(
        'CustomerPhone',
        primaryjoin="remote(Receiver.id)==foreign(CustomerPhone.entity_id)",
        uselist=True)

    @hybrid_property
    def mobiles(self):
        return CustomerPhone.query.filter_by(entity_id=self.id).all()