office templates
This commit is contained in:
@@ -459,6 +459,30 @@ def get_product_office():
|
|||||||
result = OfficeDashboardService.get_office_products(filters)
|
result = OfficeDashboardService.get_office_products(filters)
|
||||||
return jsonify(result)
|
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'])
|
@api.route('/web/contents', methods=['GET'])
|
||||||
# @token_required
|
# @token_required
|
||||||
|
|||||||
@@ -4,7 +4,8 @@ from app.api.services.base_service import BaseService
|
|||||||
from sqlalchemy import func, desc
|
from sqlalchemy import func, desc
|
||||||
from datetime import datetime, timedelta, timezone
|
from datetime import datetime, timedelta, timezone
|
||||||
from app.extensions import db
|
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):
|
class OfficeDashboardService(BaseService):
|
||||||
@@ -145,3 +146,41 @@ class OfficeDashboardService(BaseService):
|
|||||||
}
|
}
|
||||||
|
|
||||||
return products_result
|
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
|
||||||
|
|||||||
@@ -22,6 +22,15 @@ class CustomTemplates(db.Model):
|
|||||||
raise ValueError(f"Templates with Custom ID {custom_id} not found")
|
raise ValueError(f"Templates with Custom ID {custom_id} not found")
|
||||||
return templates
|
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):
|
def to_dict(self):
|
||||||
return {
|
return {
|
||||||
"id": self.id,
|
"id": self.id,
|
||||||
|
|||||||
@@ -25,6 +25,15 @@ class ProductsTemplates(db.Model):
|
|||||||
raise ValueError(f"Templates with Product ID {product_id} not found")
|
raise ValueError(f"Templates with Product ID {product_id} not found")
|
||||||
return templates
|
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):
|
def to_dict(self):
|
||||||
return {
|
return {
|
||||||
"id": self.id,
|
"id": self.id,
|
||||||
|
|||||||
Reference in New Issue
Block a user