From 10a3572a8ff5c8ed6fdb7e306920a940e8f3d835 Mon Sep 17 00:00:00 2001 From: Mojtaba-z Date: Sat, 24 Jan 2026 12:41:00 +0330 Subject: [PATCH] import --> is closed distribution batches dashboard --- apps/tag/services/tag_distribution_services.py | 7 +++++-- apps/tag/web/api/v1/api.py | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/apps/tag/services/tag_distribution_services.py b/apps/tag/services/tag_distribution_services.py index 7674657..92cba0f 100644 --- a/apps/tag/services/tag_distribution_services.py +++ b/apps/tag/services/tag_distribution_services.py @@ -150,17 +150,20 @@ class TagDistributionService: return {'tag_distributions': distributions, 'distributions_batch': dist_batch} - def distribution_batch_main_dashboard(self, org: Organization): + def distribution_batch_main_dashboard(self, org: Organization, is_closed: str = 'false'): """ distribution batch main page dashboard detail """ + is_closed = False if is_closed == 'false' else True + if org.type.key == 'ADM': distributions_batch = TagDistributionBatch.objects.prefetch_related('distributions') else: distributions_batch = TagDistributionBatch.objects.filter( Q(assigner_org=org) | - Q(assigned_org=org) + Q(assigned_org=org), + is_closed=is_closed, ) data = distributions_batch.aggregate( diff --git a/apps/tag/web/api/v1/api.py b/apps/tag/web/api/v1/api.py index 94b4e7c..3fcd00e 100644 --- a/apps/tag/web/api/v1/api.py +++ b/apps/tag/web/api/v1/api.py @@ -563,6 +563,7 @@ class TagDistributionBatchViewSet( dashboard of main page """ org = get_organization_by_user(request.user) - dashboard_data = self.distribution_batch_main_dashboard(org=org) + params = self.request.query_params # noqa + dashboard_data = self.distribution_batch_main_dashboard(org=org, is_closed=params.get('is_closed')) return Response(dashboard_data, status=status.HTTP_200_OK)