color style
This commit is contained in:
@@ -208,6 +208,14 @@ def get_myproduct_templates_activate():
|
||||
response = MyProductsService.process_set_template(data)
|
||||
return response
|
||||
|
||||
@api.route("/panel/account/colorstyle/activate", methods=["POST"])
|
||||
# @token_required
|
||||
def get_myproduct_colorstyle_activate():
|
||||
data = request.get_json()
|
||||
# logger.info(f"Route Product Template Data ==>>>> {data}")
|
||||
response = MyProductsService.process_set_colorstyle(data)
|
||||
return response
|
||||
|
||||
|
||||
@api.route("/panel/contacts", methods=["POST"])
|
||||
def merms_contacts():
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
from marshmallow import Schema, fields
|
||||
|
||||
class MyProductSetColorStyleSchema(Schema):
|
||||
token = fields.Str(required=True)
|
||||
uid = fields.Str(required=True)
|
||||
product_id = fields.Str(required=True)
|
||||
color_style_uid = fields.Str(required=True)
|
||||
|
||||
@@ -4,6 +4,7 @@ from flask import session, jsonify
|
||||
|
||||
from app.api.enums import SettingsItemsData, KafkaMessage
|
||||
from app.api.schemas.myproduct_external_url import MyProductExternalUrlSchema
|
||||
from app.api.schemas.myproduct_set_colorstyle import MyProductSetColorStyleSchema
|
||||
from app.api.schemas.myproduct_set_template import MyProductSetTemplateSchema
|
||||
from app.utils.logger import logger
|
||||
from app.api.services.base_service import BaseService
|
||||
@@ -30,6 +31,52 @@ class MyProductsService(BaseService):
|
||||
def process_provision_actions(data):
|
||||
pass
|
||||
|
||||
@staticmethod
|
||||
def process_set_colorstyle(data):
|
||||
try:
|
||||
with db.session.begin():
|
||||
# logger.info(f"Incoming MyProduct data ==>>>> {data}")
|
||||
validated_data = MyProductsService.validate_data(data, MyProductSetColorStyleSchema())
|
||||
token = validated_data.get('token')
|
||||
uid = validated_data.get('uid')
|
||||
color_style_uid = validated_data.get('color_style_uid')
|
||||
product_id = validated_data.get('product_id')
|
||||
|
||||
member_data = Members.get_member_by_uid(uid)
|
||||
member_id = member_data.id
|
||||
|
||||
# is this a valid olor scheme
|
||||
colorStyle= ProductsColorStyle.get_colorstyle_by_product_id_and_uid(product_id, color_style_uid)
|
||||
if colorStyle and colorStyle.color_style != '':
|
||||
MembersProducts.set_member_product_colorstyle(member_id, product_id, color_style_uid)
|
||||
|
||||
response_data = {}
|
||||
response_data = {
|
||||
"product_id": product_id,
|
||||
"color_style_uid": color_style_uid,
|
||||
"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_set_template(data):
|
||||
try:
|
||||
@@ -154,9 +201,10 @@ class MyProductsService(BaseService):
|
||||
|
||||
response_data = {
|
||||
"product_id": product_id,
|
||||
"current_colorstyle_uid": memberSubscription.colorstyle if memberSubscription else None,
|
||||
"current_template_uid": memberSubscription.product_template if memberSubscription else None,
|
||||
"custom_template_name": memberSubscription.custom_template if memberSubscription else '',
|
||||
"templates": color_style_data,
|
||||
"color_styles": color_style_data,
|
||||
"last_update": datetime.datetime.utcnow(),
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user