office templates

This commit is contained in:
CHIEFSOFT\ameye
2025-09-20 21:35:07 -04:00
parent 4d894d8214
commit 9809d3e7f3
4 changed files with 82 additions and 1 deletions
+24
View File
@@ -459,6 +459,30 @@ def get_product_office():
result = OfficeDashboardService.get_office_products(filters)
return jsonify(result)
@api.route('/office/product-templates', methods=['GET'])
def get_product_templates():
# Call the dashboard service
filters = {
'product_id': request.args.get('product_id'),
'provision_name': request.args.get('provision_name'),
'page': request.args.get('page', 1),
'limit': request.args.get('limit', 20)
}
result = OfficeDashboardService.get_office_product_templates(filters)
return jsonify(result)
@api.route('/office/custom-templates', methods=['GET'])
def get_custom_templates():
# Call the dashboard service
filters = {
'custom_id': request.args.get('custom_id'),
'provision_name': request.args.get('provision_name'),
'page': request.args.get('page', 1),
'limit': request.args.get('limit', 20)
}
result = OfficeDashboardService.get_office_custom_templates(filters)
return jsonify(result)
# =====================================================
@api.route('/web/contents', methods=['GET'])
# @token_required
+40 -1
View File
@@ -4,7 +4,8 @@ from app.api.services.base_service import BaseService
from sqlalchemy import func, desc
from datetime import datetime, timedelta, timezone
from app.extensions import db
from app.models import MembersProducts, Products, Members, ProductsDetails, ProductsDetails, ProvisionActions, Payments
from app.models import MembersProducts, Products, Payments, \
ProductsTemplates, CustomTemplates
class OfficeDashboardService(BaseService):
@@ -145,3 +146,41 @@ class OfficeDashboardService(BaseService):
}
return products_result
@staticmethod
def get_office_product_templates(filters):
templates = ProductsTemplates.get_template_for_office(filters)
templates_data = []
if templates:
for t in templates:
templates_data.append({
'id': t.id,
'uid': t.uid,
'product_id': t.product_id,
'provision_name': t.provision_name,
'added': t.added.isoformat() if t.added else None,
})
templates_result = {
"templates": templates_data,
}
return templates_result
@staticmethod
def get_office_custom_templates(filters):
templates = CustomTemplates.get_template_for_office(filters)
templates_data = []
if templates:
for t in templates:
templates_data.append({
'id': t.id,
'uid': t.uid,
'custom_id': t.custom_id,
'provision_name': t.provision_name,
'added': t.added.isoformat() if t.added else None,
})
templates_result = {
"templates": templates_data,
}
return templates_result
+9
View File
@@ -22,6 +22,15 @@ class CustomTemplates(db.Model):
raise ValueError(f"Templates with Custom ID {custom_id} not found")
return templates
@classmethod
def get_custom_template_for_office(cls, filters):
templates = cls.query.all()
if not templates:
raise ValueError(f"Templates not found")
return templates
def to_dict(self):
return {
"id": self.id,
+9
View File
@@ -25,6 +25,15 @@ class ProductsTemplates(db.Model):
raise ValueError(f"Templates with Product ID {product_id} not found")
return templates
@classmethod
def get_template_for_office(cls, filters):
templates = cls.query.all()
if not templates:
raise ValueError(f"Templates not found")
return templates
def to_dict(self):
return {
"id": self.id,