diff --git a/apps/tag/services/tag_batch_service.py b/apps/tag/services/tag_batch_service.py index 941bc84..fc4b320 100644 --- a/apps/tag/services/tag_batch_service.py +++ b/apps/tag/services/tag_batch_service.py @@ -1,4 +1,4 @@ -from django.db.models import Sum, Q, Count +from django.db.models import Sum, Q, Count, QuerySet from django.db.models.functions import Coalesce from apps.authentication.models import Organization @@ -11,12 +11,12 @@ class TagBatchService: services of tag batch """ - def tag_batch_main_dashboard(self, org: Organization = None): + def tag_batch_main_dashboard(self, org: Organization = None, batch: QuerySet[TagBatch] = None): """ dashboard data of batch main page """ - qs = TagBatch.objects.select_related('organization') + qs = TagBatch.objects.select_related('organization') if not batch else batch if org.type.key != 'ADM': child_orgs = get_all_org_child(org) # noqa diff --git a/apps/tag/web/api/v1/api.py b/apps/tag/web/api/v1/api.py index ada7f9a..961a1c1 100644 --- a/apps/tag/web/api/v1/api.py +++ b/apps/tag/web/api/v1/api.py @@ -350,6 +350,27 @@ class TagBatchViewSet(BaseViewSet, SoftDeleteMixin, DynamicSearchMixin, TagBatch return Response(dashboard_data, status=status.HTTP_200_OK) + @action( + methods=['get'], + detail=True, + url_name='inner_dashboard', + url_path='inner_dashboard', + name='inner_dashboard', + ) + def inner_dashboard(self, request, pk=None): + """ + dashboard of tag batches inner page by id + """ + + org = get_organization_by_user(request.user) + + dashboard_data = self.tag_batch_main_dashboard( + org=org, + batch=self.queryset.filter(id=self.get_object().id) + ) + + return Response(dashboard_data, status=status.HTTP_200_OK) + def destroy(self, request, pk=None, *args, **kwargs): """ soft delete batch with tag items