add - my inventories by quota
This commit is contained in:
@@ -105,6 +105,28 @@ class InventoryEntryViewSet(BaseViewSet, SoftDeleteMixin, viewsets.ModelViewSet,
|
|||||||
self.upload_confirmation_document(request, inventory=pk)
|
self.upload_confirmation_document(request, inventory=pk)
|
||||||
return Response(status=status.HTTP_200_OK)
|
return Response(status=status.HTTP_200_OK)
|
||||||
|
|
||||||
|
@action(
|
||||||
|
methods=['get'],
|
||||||
|
detail=True,
|
||||||
|
url_path='my_entries_by_quota',
|
||||||
|
url_name='my_entries_by_quota',
|
||||||
|
name='my_entries_by_quota'
|
||||||
|
)
|
||||||
|
def my_inventory_entries_by_quota(self, request, pk=None):
|
||||||
|
""" list of my inventory entries """
|
||||||
|
|
||||||
|
org = get_organization_by_user(request.user)
|
||||||
|
entries = self.get_queryset(
|
||||||
|
visibility_by_org_scope=True
|
||||||
|
) if org.free_visibility_by_scope else self.get_queryset().filter(organization=org, quota_id=pk)
|
||||||
|
queryset = self.filter_query(entries) # return by search param or all objects
|
||||||
|
|
||||||
|
# paginate & response
|
||||||
|
page = self.paginate_queryset(queryset)
|
||||||
|
if page is not None: # noqa
|
||||||
|
serializer = self.get_serializer(page, many=True)
|
||||||
|
return self.get_paginated_response(serializer.data)
|
||||||
|
|
||||||
@action(
|
@action(
|
||||||
methods=['get'],
|
methods=['get'],
|
||||||
detail=False,
|
detail=False,
|
||||||
|
|||||||
Reference in New Issue
Block a user