color style
This commit is contained in:
@@ -79,6 +79,6 @@ class SettingsItemsData:
|
||||
def get_site_blog_connect_settings():
|
||||
data = {
|
||||
"boolean_blog_connect_show": {"name": 'Show Blog Section', "controls": 'SELECT_NO_YES',
|
||||
"active": True, "list_order": 0},
|
||||
"active": True, "list_order": 0},
|
||||
}
|
||||
return data
|
||||
@@ -115,6 +115,7 @@ def merms_account():
|
||||
response = AccountService.process_request(data)
|
||||
return response
|
||||
|
||||
|
||||
@api.route("/panel/account/profile", methods=["POST"])
|
||||
@jwt_required()
|
||||
def merms_account_profile():
|
||||
@@ -189,6 +190,16 @@ def get_myproduct_templates():
|
||||
return response
|
||||
|
||||
|
||||
@api.route("/panel/account/products/color-styles", methods=["POST"])
|
||||
# @token_required
|
||||
def get_myproduct_colorstyles():
|
||||
# Call the ColorStyles service
|
||||
data = request.get_json()
|
||||
# logger.info(f"Route Product ColorStyles Data ==>>>> {data}")
|
||||
response = MyProductsService.mpproduct_colostyles_data(data)
|
||||
return response
|
||||
|
||||
|
||||
@api.route("/panel/account/template/activate", methods=["POST"])
|
||||
# @token_required
|
||||
def get_myproduct_templates_activate():
|
||||
@@ -205,6 +216,7 @@ def merms_contacts():
|
||||
response = ContactService.process_request(data)
|
||||
return response
|
||||
|
||||
|
||||
@api.route("/panel/comments", methods=["POST"])
|
||||
def merms_site_comments():
|
||||
data = request.get_json()
|
||||
@@ -228,6 +240,7 @@ def myproduct_dash():
|
||||
response = MyProductsService.process_request(data)
|
||||
return response
|
||||
|
||||
|
||||
@api.route("/panel/myproduct/external-url", methods=["POST"])
|
||||
def set_external_url():
|
||||
data = request.get_json()
|
||||
@@ -382,6 +395,7 @@ def get_dashboard():
|
||||
result = OfficeDashboardService.get_dashboard_data()
|
||||
return jsonify(result)
|
||||
|
||||
|
||||
@api.route('/office/country', methods=['GET'])
|
||||
# @token_required
|
||||
def get_office_country():
|
||||
@@ -389,6 +403,7 @@ def get_office_country():
|
||||
result = OfficeCountryService.get_office_country_list()
|
||||
return jsonify(result)
|
||||
|
||||
|
||||
@api.route('/office/set-country', methods=['POST'])
|
||||
# @token_required
|
||||
def set_office_country():
|
||||
@@ -427,6 +442,7 @@ def get_subscriptions_list_office():
|
||||
response = SubscriptionsService.get_subscription_data(filters)
|
||||
return response
|
||||
|
||||
|
||||
@api.route('/office/subscription-view', methods=['GET'])
|
||||
# @token_required
|
||||
def get_subcriptions_view_office():
|
||||
@@ -438,6 +454,7 @@ def get_subcriptions_view_office():
|
||||
response = OfficeDashboardService.get_subscription_view_data(filters)
|
||||
return response
|
||||
|
||||
|
||||
@api.route('/office/template/set-custom', methods=['POST'])
|
||||
# @token_required
|
||||
def get_set_custom_template_office():
|
||||
@@ -464,6 +481,7 @@ def get_create_custom_template_office():
|
||||
response = OfficeTemplatesService.create_custom_template(data)
|
||||
return response
|
||||
|
||||
|
||||
@api.route('/office/billings', methods=['GET'])
|
||||
# @token_required
|
||||
def get_subscription_billings_office():
|
||||
@@ -490,6 +508,7 @@ def get_subscription_transaction_office():
|
||||
result = OfficeDashboardService.get_payments_data(filters)
|
||||
return jsonify(result)
|
||||
|
||||
|
||||
@api.route('/office/recent-signup', methods=['GET'])
|
||||
def get_recent_signup_office():
|
||||
# Call the dashboard service
|
||||
@@ -497,6 +516,7 @@ def get_recent_signup_office():
|
||||
result = OfficeDashboardService.get_payments_data(filters)
|
||||
return jsonify(result)
|
||||
|
||||
|
||||
@api.route('/office/right-sidebar', methods=['GET'])
|
||||
def get_office_sidebar():
|
||||
# Call the dashboard service
|
||||
@@ -504,6 +524,7 @@ def get_office_sidebar():
|
||||
result = OfficeDashboardService.get_office_sidebar(filters)
|
||||
return jsonify(result)
|
||||
|
||||
|
||||
@api.route('/office/users', methods=['GET'])
|
||||
def get_office_users():
|
||||
logger.info('API::get office users')
|
||||
@@ -511,6 +532,7 @@ def get_office_users():
|
||||
result = OfficeUsersService.get_office_users(filters)
|
||||
return jsonify(result)
|
||||
|
||||
|
||||
@api.route('/office/products', methods=['GET'])
|
||||
def get_product_office():
|
||||
# Call the dashboard service
|
||||
@@ -518,6 +540,7 @@ def get_product_office():
|
||||
result = OfficeDashboardService.get_office_products(filters)
|
||||
return jsonify(result)
|
||||
|
||||
|
||||
@api.route('/office/product-view', methods=['GET'])
|
||||
def get_product_view_office():
|
||||
# Call the dashboard service
|
||||
@@ -527,6 +550,7 @@ def get_product_view_office():
|
||||
result = OfficeDashboardService.get_office_product_detail(filters)
|
||||
return jsonify(result)
|
||||
|
||||
|
||||
@api.route('/office/product-update', methods=['POST'])
|
||||
def get_product_update_office():
|
||||
# Call the dashboard service
|
||||
@@ -556,6 +580,7 @@ def get_product_templates():
|
||||
result = OfficeDashboardService.get_office_product_templates(filters)
|
||||
return jsonify(result)
|
||||
|
||||
|
||||
@api.route('/office/account-view', methods=['GET'])
|
||||
def get_office_accoint_view():
|
||||
# Call the office account viiew
|
||||
@@ -568,6 +593,7 @@ def get_office_accoint_view():
|
||||
# return response
|
||||
return jsonify(response)
|
||||
|
||||
|
||||
@api.route('/office/custom-templates', methods=['GET'])
|
||||
def get_custom_templates():
|
||||
# Call the dashboard service
|
||||
@@ -581,6 +607,7 @@ def get_custom_templates():
|
||||
result = OfficeDashboardService.get_office_custom_templates(filters)
|
||||
return jsonify(result)
|
||||
|
||||
|
||||
# =====================================================
|
||||
@api.route('/web/contents', methods=['GET'])
|
||||
# @token_required
|
||||
@@ -590,6 +617,7 @@ def get_web_contents():
|
||||
result = WebContentsService.get_web_contents_data(provision_uid)
|
||||
return jsonify(result)
|
||||
|
||||
|
||||
# =====================================================
|
||||
@api.route('/web/contacts', methods=['POST'])
|
||||
# @token_required
|
||||
@@ -599,6 +627,7 @@ def get_web_receive_contacts():
|
||||
result = ContactService.process_save_contacts(data)
|
||||
return jsonify(result)
|
||||
|
||||
|
||||
# =====================================================
|
||||
@api.route('/web/generatives', methods=['GET'])
|
||||
def get_refresh_generatives():
|
||||
@@ -608,6 +637,7 @@ def get_refresh_generatives():
|
||||
result = GenerativesService.process_generatives_list(data)
|
||||
return jsonify(result)
|
||||
|
||||
|
||||
# =====================================================
|
||||
@api.route('/web/traffic', methods=['POST'])
|
||||
# @token_required
|
||||
@@ -636,10 +666,11 @@ def common_practice():
|
||||
# Health Check Endpoint
|
||||
@api.route("/testemail", methods=["GET"])
|
||||
def email_check():
|
||||
data ={}
|
||||
data = {}
|
||||
AccountService.process_test_email(data)
|
||||
return {"status": "ok"}, 200
|
||||
|
||||
|
||||
# Health Check Endpoint
|
||||
@api.route("/health", methods=["GET"])
|
||||
def health_check():
|
||||
|
||||
@@ -10,7 +10,7 @@ from app.api.services.base_service import BaseService
|
||||
from marshmallow import ValidationError
|
||||
from app.extensions import db
|
||||
from app.models import MembersProducts, Products, Members, ProductsDetails, ProductsDetails, ProvisionActions, \
|
||||
MembersProductsSettings, ProductsTemplates, MembersProfile, SubscriptionGenerative
|
||||
MembersProductsSettings, ProductsTemplates, MembersProfile, SubscriptionGenerative, ProductsColorStyle
|
||||
from app.api.helpers.response_helper import ResponseHelper
|
||||
from app.api.schemas.myproduct import MyProductSchema
|
||||
from app.api.schemas.provision import ProvisionSchema
|
||||
@@ -124,6 +124,63 @@ class MyProductsService(BaseService):
|
||||
db.session.rollback()
|
||||
return ResponseHelper.internal_server_error()
|
||||
|
||||
@staticmethod
|
||||
def mpproduct_colostyles_data(data):
|
||||
try:
|
||||
with db.session.begin():
|
||||
# logger.info(f"Incoming MyProduct data ==>>>> {data}")
|
||||
validated_data = MyProductsService.validate_data(data, MyProductSchema())
|
||||
token = validated_data.get('token')
|
||||
uid = validated_data.get('uid')
|
||||
member_data = Members.get_member_by_uid(uid)
|
||||
member_id = member_data.id
|
||||
|
||||
product_id = validated_data.get('product_id')
|
||||
color_style_data = []
|
||||
memberSubscription = MembersProducts.get_member_product_by_product_member_id(member_id, product_id)
|
||||
if memberSubscription:
|
||||
colorStyles = ProductsColorStyle.get_colorstyle_by_product_id(product_id)
|
||||
# templates = ProductsTemplates.get_template_by_product_id(product_id)
|
||||
for t in colorStyles:
|
||||
color_style_data.append({
|
||||
'id': t.id,
|
||||
'template_uid': t.uid,
|
||||
'color_style_uid': t.uid,
|
||||
'color_code': t.color_code,
|
||||
'title': t.name,
|
||||
'active': t.status,
|
||||
'added': t.added.isoformat() if t.added else None
|
||||
})
|
||||
|
||||
response_data = {
|
||||
"product_id": product_id,
|
||||
"current_template_uid": memberSubscription.product_template if memberSubscription else None,
|
||||
"custom_template_name": memberSubscription.custom_template if memberSubscription else '',
|
||||
"templates": color_style_data,
|
||||
"last_update": datetime.datetime.utcnow(),
|
||||
}
|
||||
|
||||
return ResponseHelper.success(data=response_data)
|
||||
|
||||
|
||||
except ValidationError as err:
|
||||
|
||||
logger.error(f"Validation Error: {getattr(err, 'messages', str(err))}")
|
||||
db.session.rollback()
|
||||
return ResponseHelper.unprocessable_entity(result_description="Validation exception")
|
||||
|
||||
except ValueError as err:
|
||||
logger.error(f"{getattr(err, 'messages', str(err))}")
|
||||
db.session.rollback()
|
||||
return ResponseHelper.error(result_description=str(err))
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"An error occurred: {str(e)}", exc_info=True)
|
||||
db.session.rollback()
|
||||
return ResponseHelper.internal_server_error()
|
||||
|
||||
|
||||
|
||||
@staticmethod
|
||||
def process_provision(data):
|
||||
try:
|
||||
|
||||
@@ -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