fix filter
This commit is contained in:
@@ -3,6 +3,10 @@ from app.extensions import db
|
||||
from app.models.charge import Charge
|
||||
from sqlalchemy.orm import relationship
|
||||
from sqlalchemy.sql import func
|
||||
import logging
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class ProductsTemplates(db.Model):
|
||||
@@ -27,8 +31,24 @@ class ProductsTemplates(db.Model):
|
||||
return templates
|
||||
|
||||
@classmethod
|
||||
def get_template_for_office(cls, filters):
|
||||
templates = cls.query.all()
|
||||
def get_template_for_office(cls, product_id=None, provision_name=None, page=1, limit=20):
|
||||
|
||||
query = cls.query
|
||||
logger.info(f"Get Templates for Office Product")
|
||||
|
||||
if product_id:
|
||||
query = query.filter(cls.product_id == product_id)
|
||||
|
||||
if provision_name:
|
||||
query = query.filter(cls.provision_name == provision_name)
|
||||
|
||||
# Order by created_at descending (newest first)
|
||||
query = query.order_by(cls.added.desc())
|
||||
|
||||
# Get total count before pagination
|
||||
total_count = query.count()
|
||||
|
||||
templates = query.all()
|
||||
|
||||
if not templates:
|
||||
raise ValueError(f"Templates not found")
|
||||
|
||||
Reference in New Issue
Block a user