add - quota distributions assigned by target organization
This commit is contained in:
@@ -131,6 +131,37 @@ class QuotaDistributionViewSet(BaseViewSet, SoftDeleteMixin, viewsets.ModelViewS
|
|||||||
serializer = self.get_serializer(page, many=True) # noqa
|
serializer = self.get_serializer(page, many=True) # noqa
|
||||||
return self.get_paginated_response(serializer.data)
|
return self.get_paginated_response(serializer.data)
|
||||||
|
|
||||||
|
@action(
|
||||||
|
methods=['get'],
|
||||||
|
detail=False,
|
||||||
|
url_name='quota_distributions_assigned_by_org',
|
||||||
|
url_path='quota_distributions_assigned_by_org',
|
||||||
|
name='quota_distributions_assigned_by_org'
|
||||||
|
)
|
||||||
|
def quota_distributions_assigned_by_org(self, request):
|
||||||
|
"""
|
||||||
|
list of distributions pf a quota that target org is assigner
|
||||||
|
"""
|
||||||
|
query = self.request.query_params # noqa
|
||||||
|
|
||||||
|
target_org = product_models.Organization.objects.filter(
|
||||||
|
id=query.get('org_id')
|
||||||
|
).first()
|
||||||
|
|
||||||
|
target_quota = product_models.Quota.objects.filter(
|
||||||
|
id=query.get('quota_id')
|
||||||
|
).first()
|
||||||
|
|
||||||
|
queryset = self.filter_query(self.get_queryset().filter(
|
||||||
|
assigner_organization=target_org,
|
||||||
|
quota=target_quota
|
||||||
|
))
|
||||||
|
|
||||||
|
page = self.paginate_queryset(queryset)
|
||||||
|
if page is not None: # noqa
|
||||||
|
serializer = self.get_serializer(page, many=True) # noqa
|
||||||
|
return self.get_paginated_response(serializer.data)
|
||||||
|
|
||||||
@action(
|
@action(
|
||||||
methods=['put'],
|
methods=['put'],
|
||||||
detail=True,
|
detail=True,
|
||||||
|
|||||||
Reference in New Issue
Block a user