Implement pagination for stock history tracking API (#4629)

This commit is contained in:
Oliver 2023-04-18 22:40:31 +10:00 committed by GitHub
parent ae05c68417
commit b0f6021002
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1188,7 +1188,12 @@ class StockTrackingList(ListAPI):
"""List all stock tracking entries."""
queryset = self.filter_queryset(self.get_queryset())
serializer = self.get_serializer(queryset, many=True)
page = self.paginate_queryset(queryset)
if page is not None:
serializer = self.get_serializer(page, many=True)
else:
serializer = self.get_serializer(queryset, many=True)
data = serializer.data
@ -1262,6 +1267,8 @@ class StockTrackingList(ListAPI):
except Exception:
pass
if page is not None:
return self.get_paginated_response(data)
if request.is_ajax():
return JsonResponse(data, safe=False)
else: