From 8435a6705b5327c6479b627156e631ee5baad49a Mon Sep 17 00:00:00 2001
From: Frank Sauerburger <frank@sauerburger.com>
Date: Fri, 20 Aug 2021 14:22:41 +0200
Subject: [PATCH] Add pagination to api plot-list

---
 uhepp_org/requirements.txt   | 1 +
 uhepp_org/uhepp_api/views.py | 6 ++++++
 2 files changed, 7 insertions(+)

diff --git a/uhepp_org/requirements.txt b/uhepp_org/requirements.txt
index bdacb88..f969b6b 100644
--- a/uhepp_org/requirements.txt
+++ b/uhepp_org/requirements.txt
@@ -6,3 +6,4 @@ django-inline-svg
 psycopg2
 django-crispy-forms
 jsonschema
+djangorestframework-link-header-pagination
diff --git a/uhepp_org/uhepp_api/views.py b/uhepp_org/uhepp_api/views.py
index 9e96349..5b2c244 100644
--- a/uhepp_org/uhepp_api/views.py
+++ b/uhepp_org/uhepp_api/views.py
@@ -7,6 +7,7 @@ from rest_framework import generics, viewsets, status
 from rest_framework.response import Response
 from rest_framework.reverse import reverse
 from rest_framework.decorators import api_view, permission_classes
+from drf_link_header_pagination import LinkHeaderPagination
 
 from uhepp_vault.models import PUBLIC_LEVEL, INTERNAL_LEVEL, PUBLIC_LEVEL, \
                                Collection, Plot
@@ -124,8 +125,13 @@ class OwnModelViewSet:
     # Related-objects operations:
     #  - Queryset filtering for related items in output, form choice
 
+class PlotPagination(LinkHeaderPagination):
+    page_size = 100
+    
+
 class PlotViewSet(viewsets.ModelViewSet):
     permission_classes = [IsCollectionOwnerOrReadOnly]
+    pagination_class = PlotPagination
 
     def create(self, request, *args, **kwds):
         serializer = self.get_serializer(data=request.data)
-- 
GitLab