add - distributions list by quota in my child orgs

This commit is contained in:
2025-11-25 10:40:16 +03:30
parent 67904fd1a8
commit a87670e14e

View File

@@ -8,6 +8,7 @@ from rest_framework.decorators import action
from rest_framework.exceptions import APIException
from rest_framework.response import Response
from apps.authentication.services.service import get_all_org_child
from apps.core.api import BaseViewSet
from apps.core.mixins.search_mixin import DynamicSearchMixin
from apps.core.mixins.soft_delete_mixin import SoftDeleteMixin
@@ -433,11 +434,13 @@ class QuotaViewSet(BaseViewSet, SoftDeleteMixin, viewsets.ModelViewSet, DynamicS
""" list of distributions by quota """
my_org = get_organization_by_user(request.user)
my_org_child_list = get_all_org_child(my_org)
try:
quota = self.get_object()
queryset = self.filter_query(
quota.distributions_assigned.filter(
assigner_organization=my_org
Q(assigner_organization=my_org) |
Q(assigned_organization__in=my_org_child_list)
).order_by('-modify_date')
) # return by search param or all objects