import --> is closed distribution batches dashboard

This commit is contained in:
2026-01-24 12:41:00 +03:30
parent bf4b3d4422
commit 10a3572a8f
2 changed files with 7 additions and 3 deletions

View File

@@ -150,17 +150,20 @@ class TagDistributionService:
return {'tag_distributions': distributions, 'distributions_batch': dist_batch} 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 distribution batch main page dashboard detail
""" """
is_closed = False if is_closed == 'false' else True
if org.type.key == 'ADM': if org.type.key == 'ADM':
distributions_batch = TagDistributionBatch.objects.prefetch_related('distributions') distributions_batch = TagDistributionBatch.objects.prefetch_related('distributions')
else: else:
distributions_batch = TagDistributionBatch.objects.filter( distributions_batch = TagDistributionBatch.objects.filter(
Q(assigner_org=org) | Q(assigner_org=org) |
Q(assigned_org=org) Q(assigned_org=org),
is_closed=is_closed,
) )
data = distributions_batch.aggregate( data = distributions_batch.aggregate(

View File

@@ -563,6 +563,7 @@ class TagDistributionBatchViewSet(
dashboard of main page dashboard of main page
""" """
org = get_organization_by_user(request.user) 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) return Response(dashboard_data, status=status.HTTP_200_OK)