fix image load
This commit is contained in:
@@ -406,6 +406,12 @@ def myproduct_configuration():
|
|||||||
response = MyProductsService.product_configuration(data)
|
response = MyProductsService.product_configuration(data)
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
@api.route("/panel/myproduct/template-config", methods=["POST"])
|
||||||
|
def myproduct_template_config():
|
||||||
|
data = request.get_json()
|
||||||
|
logger.info(f"Route Save MyProduct_Template_Config ==>>>> {data}")
|
||||||
|
response = MyProductsService.template_configuration(data)
|
||||||
|
return response
|
||||||
|
|
||||||
@api.route("/panel/myproduct/settings/values", methods=["POST"])
|
@api.route("/panel/myproduct/settings/values", methods=["POST"])
|
||||||
def myproduct_settings_values():
|
def myproduct_settings_values():
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ from email.mime.text import MIMEText
|
|||||||
from email.mime.multipart import MIMEMultipart
|
from email.mime.multipart import MIMEMultipart
|
||||||
import datetime
|
import datetime
|
||||||
import jwt
|
import jwt
|
||||||
|
import requests
|
||||||
|
|
||||||
class BaseService:
|
class BaseService:
|
||||||
TRANSACTION_TYPE = None
|
TRANSACTION_TYPE = None
|
||||||
@@ -357,6 +358,38 @@ class BaseService:
|
|||||||
KafkaIntegration.send_loan_request(loan_data = loan_data, request_id = request_id, topic = topic)
|
KafkaIntegration.send_loan_request(loan_data = loan_data, request_id = request_id, topic = topic)
|
||||||
KafkaIntegration.flush()
|
KafkaIntegration.flush()
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_site_imges_data(provision_uid, primary_server, provision_port, selected_flavor):
|
||||||
|
destination_server = "http://" + str(primary_server) + ":" + str(provision_port)
|
||||||
|
api_url = destination_server + "/api/props"
|
||||||
|
try:
|
||||||
|
payload = {'provision_uid': provision_uid, 'flavor': selected_flavor}
|
||||||
|
logger.info(f"api_url: {str(api_url)}")
|
||||||
|
logger.info(f"selected_flavor: {str(selected_flavor)}")
|
||||||
|
|
||||||
|
# Make the GET request
|
||||||
|
res_data = []
|
||||||
|
response = requests.get(api_url, params=payload)
|
||||||
|
if response.status_code == 200:
|
||||||
|
logger.info(f"Response Site Images: {res_data}")
|
||||||
|
# Convert the JSON response to a Python dictionary
|
||||||
|
res_data = response.json()
|
||||||
|
logger.info(f"Response Site Images: {res_data}")
|
||||||
|
|
||||||
|
response_data = {
|
||||||
|
"provision_uid": provision_uid,
|
||||||
|
"data": res_data,
|
||||||
|
# "product_id": product_id,
|
||||||
|
}
|
||||||
|
|
||||||
|
return response_data
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"An error occurred while get_site_imges_data data: {str(e)}", exc_info=True)
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# @classmethod
|
# @classmethod
|
||||||
# def calculate_charges(cls, offer, amount):
|
# def calculate_charges(cls, offer, amount):
|
||||||
|
|||||||
@@ -45,8 +45,8 @@ class MyProductsService(BaseService):
|
|||||||
member_data = Members.get_member_by_uid(uid)
|
member_data = Members.get_member_by_uid(uid)
|
||||||
member_id = member_data.id
|
member_id = member_data.id
|
||||||
|
|
||||||
# is this a valid color scheme
|
# is this a valid color scheme
|
||||||
colorStyle= ProductsColorStyle.get_colorstyle_by_product_id_and_uid(product_id, color_style_uid)
|
colorStyle = ProductsColorStyle.get_colorstyle_by_product_id_and_uid(product_id, color_style_uid)
|
||||||
if colorStyle and colorStyle.color_style != '':
|
if colorStyle and colorStyle.color_style != '':
|
||||||
MembersProducts.set_member_product_colorstyle(member_id, product_id, color_style_uid)
|
MembersProducts.set_member_product_colorstyle(member_id, product_id, color_style_uid)
|
||||||
|
|
||||||
@@ -76,7 +76,6 @@ class MyProductsService(BaseService):
|
|||||||
db.session.rollback()
|
db.session.rollback()
|
||||||
return ResponseHelper.internal_server_error()
|
return ResponseHelper.internal_server_error()
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def process_set_template(data):
|
def process_set_template(data):
|
||||||
try:
|
try:
|
||||||
@@ -230,8 +229,6 @@ class MyProductsService(BaseService):
|
|||||||
db.session.rollback()
|
db.session.rollback()
|
||||||
return ResponseHelper.internal_server_error()
|
return ResponseHelper.internal_server_error()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def process_provision(data):
|
def process_provision(data):
|
||||||
try:
|
try:
|
||||||
@@ -627,9 +624,13 @@ class MyProductsService(BaseService):
|
|||||||
memberSubscription = MembersProducts.get_member_product_by_product_member_id(member_id, product_id)
|
memberSubscription = MembersProducts.get_member_product_by_product_member_id(member_id, product_id)
|
||||||
|
|
||||||
if memberSubscription is not None:
|
if memberSubscription is not None:
|
||||||
|
custom_template = "" if (
|
||||||
|
memberSubscription.custom_template is None or len(memberSubscription.custom_template)
|
||||||
|
== 0) else memberSubscription.custom_template
|
||||||
|
|
||||||
# logger.info(f"Incoming MyProduct data ==>>>> {memberSubscription}")
|
# logger.info(f"Incoming MyProduct data ==>>>> {memberSubscription}")
|
||||||
product_subscription_uid = memberSubscription.uid
|
product_subscription_uid = memberSubscription.uid
|
||||||
subscription_template = memberSubscription.product_template
|
subscription_template = "" if len(custom_template) > 0 else memberSubscription.product_template
|
||||||
settingsFields = SettingsItemsData.get_site_settings_data()
|
settingsFields = SettingsItemsData.get_site_settings_data()
|
||||||
templateData = []
|
templateData = []
|
||||||
homeFields = SettingsItemsData.get_site_home_settings()
|
homeFields = SettingsItemsData.get_site_home_settings()
|
||||||
@@ -663,7 +664,8 @@ class MyProductsService(BaseService):
|
|||||||
"data": contactFields, "list_order": 5},
|
"data": contactFields, "list_order": 5},
|
||||||
"social_tab": {"title": 'Socials', "controls": 'social', "active": '', "custom": False,
|
"social_tab": {"title": 'Socials', "controls": 'social', "active": '', "custom": False,
|
||||||
"data": socialFields, "list_order": 6},
|
"data": socialFields, "list_order": 6},
|
||||||
"template_tab": {"title": 'Select Template', "controls": 'template', "active": '', "custom": True,
|
"template_tab": {"title": 'Select Template', "controls": 'template', "active": '',
|
||||||
|
"custom": True,
|
||||||
"data": templateData, "list_order": 17},
|
"data": templateData, "list_order": 17},
|
||||||
"color_scheme_tab": {"title": 'Color Scheme', "controls": 'color-scheme', "active": '',
|
"color_scheme_tab": {"title": 'Color Scheme', "controls": 'color-scheme', "active": '',
|
||||||
"custom": True, "data": {}, "list_order": 18}
|
"custom": True, "data": {}, "list_order": 18}
|
||||||
@@ -713,6 +715,7 @@ class MyProductsService(BaseService):
|
|||||||
"settings_items": settings_items,
|
"settings_items": settings_items,
|
||||||
"member_id": member_id,
|
"member_id": member_id,
|
||||||
"subscription_template": subscription_template,
|
"subscription_template": subscription_template,
|
||||||
|
"custom_template_name": custom_template,
|
||||||
"product_subscription_uid": product_subscription_uid,
|
"product_subscription_uid": product_subscription_uid,
|
||||||
"blog_connect": blogConnect
|
"blog_connect": blogConnect
|
||||||
}
|
}
|
||||||
@@ -802,3 +805,98 @@ class MyProductsService(BaseService):
|
|||||||
logger.error(f"An error occurred: {str(e)}", exc_info=True)
|
logger.error(f"An error occurred: {str(e)}", exc_info=True)
|
||||||
db.session.rollback()
|
db.session.rollback()
|
||||||
return ResponseHelper.internal_server_error()
|
return ResponseHelper.internal_server_error()
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def template_configuration(data):
|
||||||
|
try:
|
||||||
|
with db.session.begin():
|
||||||
|
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')
|
||||||
|
|
||||||
|
product_subscription_uid = ''
|
||||||
|
product_data = Products.get_product_by_product_id(product_id)
|
||||||
|
if not product_data:
|
||||||
|
return {
|
||||||
|
"message": "Please provide valid product_id",
|
||||||
|
"error_message": "Error - Please select a valid product to view",
|
||||||
|
"data": None,
|
||||||
|
"error": f"Product with ID {product_id} does not exist."
|
||||||
|
}, 400
|
||||||
|
|
||||||
|
product_description = ProductsDetails.get_product_details_with_product_id(product_id)
|
||||||
|
productDataStatus = product_data.status
|
||||||
|
|
||||||
|
memberSubscription = MembersProducts.get_member_product_by_product_member_id(member_id, product_id)
|
||||||
|
template_images = []
|
||||||
|
template_name=''
|
||||||
|
if memberSubscription is not None:
|
||||||
|
custom_template = "" if (
|
||||||
|
memberSubscription.custom_template is None or len(memberSubscription.custom_template)
|
||||||
|
== 0) else memberSubscription.custom_template
|
||||||
|
|
||||||
|
# logger.info(f"Incoming MyProduct data ==>>>> {memberSubscription}")
|
||||||
|
product_subscription_uid = memberSubscription.uid
|
||||||
|
subscription_template = "" if len(custom_template) > 0 else memberSubscription.product_template
|
||||||
|
settingsFields = SettingsItemsData.get_site_settings_data()
|
||||||
|
templateData = []
|
||||||
|
# homeFields = SettingsItemsData.get_site_home_settings()
|
||||||
|
# footerFields = SettingsItemsData.get_site_footer_settings()
|
||||||
|
# contactFields = SettingsItemsData.get_site_contact_items()
|
||||||
|
# socialFields = SettingsItemsData.get_site_social_settings_data()
|
||||||
|
# aboutFields = SettingsItemsData.get_site_about_items()
|
||||||
|
# testimonialFields = SettingsItemsData.get_site_testimonial_settings()
|
||||||
|
# blogConnectFields = SettingsItemsData.get_site_blog_connect_settings()
|
||||||
|
|
||||||
|
blogConnect = False
|
||||||
|
if product_data.blog_product_id != None and product_data.blog_product_id != '':
|
||||||
|
blogConnect = True
|
||||||
|
blog_product_data = Products.get_product_by_product_id(product_data.blog_product_id)
|
||||||
|
|
||||||
|
settings_items = {}
|
||||||
|
if product_id == "A000001" or product_id == "A000002": ## should be config or data driven not hard coded
|
||||||
|
settings_items = {}
|
||||||
|
|
||||||
|
if memberSubscription.product_template:
|
||||||
|
selectedTemplate = ProductsTemplates.get_template_by_uid(
|
||||||
|
str(memberSubscription.product_template))
|
||||||
|
if selectedTemplate:
|
||||||
|
selected_flavor = selectedTemplate.flavor
|
||||||
|
template_name = selectedTemplate.name
|
||||||
|
|
||||||
|
template_images = BaseService.get_site_imges_data(memberSubscription.uid,
|
||||||
|
memberSubscription.primary_server,
|
||||||
|
memberSubscription.provision_port,
|
||||||
|
selected_flavor)
|
||||||
|
|
||||||
|
# Simulate processing
|
||||||
|
response_data = {
|
||||||
|
"settings_items": settings_items,
|
||||||
|
"member_id": member_id,
|
||||||
|
"subscription_template": subscription_template,
|
||||||
|
"template_name": template_name,
|
||||||
|
"product_subscription_uid": product_subscription_uid,
|
||||||
|
"blog_connect": blogConnect,
|
||||||
|
"template_images": template_images
|
||||||
|
}
|
||||||
|
|
||||||
|
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()
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ class WebContentsService(BaseService):
|
|||||||
if selectedTemplate:
|
if selectedTemplate:
|
||||||
selected_flavor = selectedTemplate.flavor
|
selected_flavor = selectedTemplate.flavor
|
||||||
|
|
||||||
WebContentsService.get_site_imges_data(provision_uid, membersSubResult.primary_server,
|
BaseService.get_site_imges_data(provision_uid, membersSubResult.primary_server,
|
||||||
membersSubResult.provision_port, selected_flavor)
|
membersSubResult.provision_port, selected_flavor)
|
||||||
|
|
||||||
if membersSubResult.colorstyle is not None and membersSubResult.colorstyle != '':
|
if membersSubResult.colorstyle is not None and membersSubResult.colorstyle != '':
|
||||||
@@ -144,32 +144,32 @@ class WebContentsService(BaseService):
|
|||||||
logger.error(f"An error occurred while getting dashboard data: {str(e)}", exc_info=True)
|
logger.error(f"An error occurred while getting dashboard data: {str(e)}", exc_info=True)
|
||||||
return jsonify({"message": "Internal Server Error"}), 500
|
return jsonify({"message": "Internal Server Error"}), 500
|
||||||
|
|
||||||
@staticmethod
|
# @staticmethod
|
||||||
def get_site_imges_data(provision_uid, primary_server, provision_port, selected_flavor):
|
# def get_site_imges_data(provision_uid, primary_server, provision_port, selected_flavor):
|
||||||
destination_server = "http://" + str(primary_server) + ":" + str(provision_port)
|
# destination_server = "http://" + str(primary_server) + ":" + str(provision_port)
|
||||||
api_url = destination_server + "/api/props"
|
# api_url = destination_server + "/api/props"
|
||||||
try:
|
# try:
|
||||||
payload = {'provision_uid': provision_uid, 'flavor': selected_flavor}
|
# payload = {'provision_uid': provision_uid, 'flavor': selected_flavor}
|
||||||
logger.info(f"api_url: {str(api_url)}")
|
# logger.info(f"api_url: {str(api_url)}")
|
||||||
logger.info(f"selected_flavor: {str(selected_flavor)}")
|
# logger.info(f"selected_flavor: {str(selected_flavor)}")
|
||||||
|
#
|
||||||
# Make the GET request
|
# # Make the GET request
|
||||||
res_data = []
|
# res_data = []
|
||||||
response = requests.get(api_url, params=payload)
|
# response = requests.get(api_url, params=payload)
|
||||||
if response.status_code == 200:
|
# if response.status_code == 200:
|
||||||
logger.info(f"Response Site Images: {res_data}")
|
# logger.info(f"Response Site Images: {res_data}")
|
||||||
# Convert the JSON response to a Python dictionary
|
# # Convert the JSON response to a Python dictionary
|
||||||
res_data = response.json()
|
# res_data = response.json()
|
||||||
logger.info(f"Response Site Images: {res_data}")
|
# logger.info(f"Response Site Images: {res_data}")
|
||||||
|
#
|
||||||
response_data = {
|
# response_data = {
|
||||||
"provision_uid": provision_uid,
|
# "provision_uid": provision_uid,
|
||||||
"data": res_data,
|
# "data": res_data,
|
||||||
# "product_id": product_id,
|
# # "product_id": product_id,
|
||||||
}
|
# }
|
||||||
|
#
|
||||||
return response_data
|
# return response_data
|
||||||
|
#
|
||||||
except Exception as e:
|
# except Exception as e:
|
||||||
logger.error(f"An error occurred while get_site_imges_data data: {str(e)}", exc_info=True)
|
# logger.error(f"An error occurred while get_site_imges_data data: {str(e)}", exc_info=True)
|
||||||
return None
|
# return None
|
||||||
|
|||||||
Reference in New Issue
Block a user