add - distributions list by quota in my child orgs
This commit is contained in:
@@ -8,6 +8,7 @@ from rest_framework.decorators import action
|
|||||||
from rest_framework.exceptions import APIException
|
from rest_framework.exceptions import APIException
|
||||||
from rest_framework.response import Response
|
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.api import BaseViewSet
|
||||||
from apps.core.mixins.search_mixin import DynamicSearchMixin
|
from apps.core.mixins.search_mixin import DynamicSearchMixin
|
||||||
from apps.core.mixins.soft_delete_mixin import SoftDeleteMixin
|
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 """
|
""" list of distributions by quota """
|
||||||
|
|
||||||
my_org = get_organization_by_user(request.user)
|
my_org = get_organization_by_user(request.user)
|
||||||
|
my_org_child_list = get_all_org_child(my_org)
|
||||||
try:
|
try:
|
||||||
quota = self.get_object()
|
quota = self.get_object()
|
||||||
queryset = self.filter_query(
|
queryset = self.filter_query(
|
||||||
quota.distributions_assigned.filter(
|
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')
|
).order_by('-modify_date')
|
||||||
) # return by search param or all objects
|
) # return by search param or all objects
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user