set custom template

This commit is contained in:
CHIEFSOFT\ameye
2025-10-04 09:02:37 -04:00
parent 9f60427a42
commit 172acb1e20
2 changed files with 31 additions and 18 deletions
+22 -18
View File
@@ -13,25 +13,29 @@ class OfficeTemplatesService(BaseService):
def set_office_custom_template(data):
logger.info('set_office_custom_template')
try:
# office_users = OfficeUsers.get_office_users_list()
# office_users_data = []
# if office_users:
# for t in office_users:
# office_users_data.append({
# 'id': t.id,
# 'uid': t.uid,
# 'username': t.username,
# 'firstname': t.firstname,
# 'lastname': t.lastname,
# 'acc_level': t.acc_level,
# 'status': t.status,
# 'added': t.added.isoformat() if t.added else None
# })
with db.session.begin():
subscrtiption_uid = data.get('subscrtiption_uid', '')
custom_id = data.get('custom_id', '')
office_users_result = {
"set_office_custom_template": [],
}
return office_users_result
membersSubResult = MembersProducts.get_member_product_by_subscription_uid(subscrtiption_uid)
if not membersSubResult:
return {
"message": "Invalid Subscription",
"error_message": "Error - Please select a valid product to view",
"data": None,
"error": f"Subscription with UID {subscrtiption_uid} does not exist."
}, 400
member_id = membersSubResult.member_id
logger.info(f'set_office_custom_template {member_id} {subscrtiption_uid} {custom_id}')
MembersProducts.set_member_product_custom_template(member_id, subscrtiption_uid, custom_id)
office_users_result = {
"set_office_custom_template": [],
}
return office_users_result
except Exception as e:
logger.error(f"An error occurred: {str(e)}", exc_info=True)
+9
View File
@@ -98,6 +98,15 @@ class MembersProducts(db.Model):
member_product.product_template = product_template
return product_template
@classmethod
def set_member_product_custom_template(cls, member_id, uid, custom_template):
member_product = cls.query.filter_by(member_id=str(member_id), uid=str(uid)).first()
if not member_product:
return None
logger.info(f'ACTION:::set_member_product_custom_template {member_id} {uid} {custom_template}')
member_product.custom_template = custom_template
return custom_template
@classmethod
def set_member_product_external_url(cls, member_id, product_id, external_url):
member_product = cls.query.filter_by(member_id=str(member_id), product_id=str(product_id)).first()