Hide inactive merged services from service catalogue

This commit is contained in:
A R R R Associates
2026-07-17 23:20:08 +05:30
parent 0b58bf182b
commit e219a0800c
4 changed files with 42 additions and 8 deletions
+8 -2
View File
@@ -65,7 +65,9 @@ def get_category(db: Session, category_id: int) -> ServiceCategory | None:
def list_catalogue_payload(db: Session, *, q: str = "", category_id: int | None = None, recurrence_type: str = "", engagement_type: str = "", page: int = 1, per_page: int = 20):
query = select(ServiceCatalogue).options(
query = select(ServiceCatalogue).where(
ServiceCatalogue.is_active.is_(True)
).options(
selectinload(ServiceCatalogue.service_category),
selectinload(ServiceCatalogue.default_task_templates),
selectinload(ServiceCatalogue.due_date_rules),
@@ -115,6 +117,7 @@ def list_firm_services_payload(db: Session, *, tenant_id: int, q: str = ""):
.where(
FirmServiceSelection.tenant_id == tenant_id,
FirmServiceSelection.is_enabled.is_(True),
ServiceCatalogue.is_active.is_(True),
)
)
if q.strip():
@@ -143,7 +146,10 @@ def list_disabled_catalogues(db: Session, *, tenant_id: int, q: str = ""):
)
)
query = select(ServiceCatalogue).where(~ServiceCatalogue.id.in_(enabled_subq)).options(
query = select(ServiceCatalogue).where(
ServiceCatalogue.is_active.is_(True),
~ServiceCatalogue.id.in_(enabled_subq),
).options(
selectinload(ServiceCatalogue.service_category),
selectinload(ServiceCatalogue.default_task_templates),
selectinload(ServiceCatalogue.due_date_rules),