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