moves on api
[wolnelektury.git] / src / api / pagination.py
diff --git a/src/api/pagination.py b/src/api/pagination.py
new file mode 100644 (file)
index 0000000..0c4ae09
--- /dev/null
@@ -0,0 +1,14 @@
+from rest_framework.pagination import LimitOffsetPagination, PageLink
+from rest_framework.response import Response
+
+
+class WLLimitOffsetPagination(LimitOffsetPagination):
+    def get_paginated_response(self, data):
+        return Response({
+            "member": data,
+            "totalItems": self.count,
+            "view": {
+                "previous": self.get_previous_link(),
+                "next": self.get_next_link(),
+            }
+        })