change my distributions to assigner & assigned by param
This commit is contained in:
@@ -81,16 +81,26 @@ class QuotaDistributionViewSet(viewsets.ModelViewSet):
|
||||
)
|
||||
def my_distributions(self, request):
|
||||
""" list of my distributions """
|
||||
query = self.request.query_params
|
||||
organization = get_organization_by_user(request.user)
|
||||
|
||||
# paginate queryset
|
||||
page = self.paginate_queryset(
|
||||
self.queryset.filter(
|
||||
Q(assigned_organization=organization)
|
||||
).order_by('-modify_date')
|
||||
)
|
||||
if page is not None:
|
||||
serializer = self.get_serializer(page, many=True)
|
||||
if query.get('param') == 'assigned':
|
||||
# paginate queryset
|
||||
page = self.paginate_queryset(
|
||||
self.queryset.filter(
|
||||
Q(assigned_organization=organization)
|
||||
).order_by('-modify_date')
|
||||
)
|
||||
elif query.get('param') == 'assigner':
|
||||
# paginate queryset
|
||||
page = self.paginate_queryset(
|
||||
self.queryset.filter(
|
||||
Q(assigner_organization=organization)
|
||||
).order_by('-modify_date')
|
||||
)
|
||||
|
||||
if page is not None: # noqa
|
||||
serializer = self.get_serializer(page, many=True) # noqa
|
||||
return self.get_paginated_response(serializer.data)
|
||||
|
||||
@action(
|
||||
|
||||
Reference in New Issue
Block a user