color style
This commit is contained in:
@@ -19,12 +19,14 @@ from .subscription_generative import SubscriptionGenerative
|
||||
from .generative_results import GenerativeResults
|
||||
from .office_users import OfficeUsers
|
||||
from .custom_templates import CustomTemplates
|
||||
from .products_colorstyle import ProductsColorStyle
|
||||
from .country import Country
|
||||
|
||||
__all__ = ['Members', 'Account', 'Products',
|
||||
'MembersProducts', 'MembersActions', 'MembersPending', 'ProductsDetails',
|
||||
'ProvisionActions', 'MembersProductsRefresh', 'MembersProductsSettings',
|
||||
'PasswordReset', 'MembersProfile', 'SubscriptionOptions', 'SubscriptionOptionsItems',
|
||||
'ProductsTemplates', 'Payments', 'PaymentsSession', 'SubscriptionGenerative', 'GenerativeResults',
|
||||
'CustomTemplates','Country',
|
||||
'ProductsTemplates', 'ProductsColorStyle', 'Payments', 'PaymentsSession',
|
||||
'SubscriptionGenerative', 'GenerativeResults',
|
||||
'CustomTemplates', 'Country',
|
||||
'OfficeUsers']
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
#
|
||||
|
||||
from datetime import datetime, timezone
|
||||
from app.extensions import db
|
||||
from app.models.charge import Charge
|
||||
from sqlalchemy.orm import relationship
|
||||
from sqlalchemy.sql import func
|
||||
|
||||
|
||||
class ProductsColorStyle(db.Model):
|
||||
__tablename__ = 'products_colorstyle'
|
||||
|
||||
id = db.Column(db.String, primary_key=True)
|
||||
uid = db.Column(db.String, nullable=False)
|
||||
product_id = db.Column(db.String, nullable=False)
|
||||
name = db.Column(db.String, nullable=False)
|
||||
color_style = db.Column(db.String, nullable=False)
|
||||
color_code = db.Column(db.String, nullable=False)
|
||||
status = db.Column(db.Integer, nullable=True, default=1)
|
||||
added = db.Column(db.DateTime(timezone=True), server_default=func.now(), onupdate=func.now())
|
||||
|
||||
@classmethod
|
||||
def get_colorstyle_by_product_id(cls, product_id):
|
||||
templates = cls.query.filter_by(product_id=str(product_id)).all()
|
||||
|
||||
if not templates:
|
||||
# raise ValueError(f"Templates with Product ID {product_id} not found")
|
||||
return None
|
||||
return templates
|
||||
|
||||
@classmethod
|
||||
def get_colorstyle_for_office(cls, filters):
|
||||
templates = cls.query.all()
|
||||
|
||||
if not templates:
|
||||
raise ValueError(f"Templates not found")
|
||||
return templates
|
||||
|
||||
# @classmethod
|
||||
# def get_template_by_uid(cls, template_uid):
|
||||
# selTemplate = cls.query.filter_by(uif=template_uid).first()
|
||||
# if not selTemplate:
|
||||
# return None
|
||||
# return selTemplate
|
||||
|
||||
def to_dict(self):
|
||||
return {
|
||||
"id": self.id,
|
||||
"uid": self.uid,
|
||||
"product_id": self.product_id,
|
||||
"name": self.name,
|
||||
"color_style": self.color_style,
|
||||
"color_code": self.color_code,
|
||||
"status": self.status,
|
||||
"added": self.added.isoformat() if self.added else None
|
||||
}
|
||||
|
||||
def __repr__(self):
|
||||
return f'<ProductsColorStyle {self.id}>'
|
||||
@@ -4,6 +4,7 @@ from app.models.charge import Charge
|
||||
from sqlalchemy.orm import relationship
|
||||
from sqlalchemy.sql import func
|
||||
|
||||
|
||||
class ProductsTemplates(db.Model):
|
||||
__tablename__ = 'products_templates'
|
||||
|
||||
@@ -16,7 +17,6 @@ class ProductsTemplates(db.Model):
|
||||
provision_name = db.Column(db.String, nullable=False)
|
||||
added = db.Column(db.DateTime(timezone=True), server_default=func.now(), onupdate=func.now())
|
||||
|
||||
|
||||
@classmethod
|
||||
def get_template_by_product_id(cls, product_id):
|
||||
templates = cls.query.filter_by(product_id=str(product_id)).all()
|
||||
@@ -41,7 +41,6 @@ class ProductsTemplates(db.Model):
|
||||
return None
|
||||
return selTemplate
|
||||
|
||||
|
||||
def to_dict(self):
|
||||
return {
|
||||
"id": self.id,
|
||||
@@ -51,8 +50,8 @@ class ProductsTemplates(db.Model):
|
||||
"status": self.status,
|
||||
"owner_uid": self.owner_uid,
|
||||
"provision_name": self.provision_name,
|
||||
"provision_name": self.provision_name
|
||||
"added": self.added.isoformat() if self.added else None
|
||||
}
|
||||
|
||||
def __repr__(self):
|
||||
return f'<LoanOffer {self.id}>'
|
||||
return f'<ProductsTemplates {self.id}>'
|
||||
|
||||
Reference in New Issue
Block a user