From e19003d2545fa600d3409eee5db2f61e023499aa Mon Sep 17 00:00:00 2001
From: borzechof99 <borzechof99@mi.fu-berlin.de>
Date: Sat, 26 Jun 2021 16:02:52 +0200
Subject: [PATCH] Add pagination to incompleteSports

---
 unisportomat/quiz/views.py | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/unisportomat/quiz/views.py b/unisportomat/quiz/views.py
index e27fd48..6147522 100644
--- a/unisportomat/quiz/views.py
+++ b/unisportomat/quiz/views.py
@@ -213,20 +213,23 @@ class IncompleteSportView(APIView):
     def get(self, request):
         """
         GET for api/admin/sport/incomplete/
-        Returns every incomplete Sport with its incomplete Ratings
-        TODO: Maybe Pagination
+        Returns every incomplete Sport with its incomplete Ratings in a paginated manner
         """
 
+        paginator = PageNumberWithPageSizePagination()
+        queryset = Sport.objects.iterator()
+        queryset = paginator.paginate_queryset(queryset, request)
+
         incomplete_sport_list = []
 
-        for sport in Sport.objects.iterator():
+        for sport in queryset:
 
             if not sport.is_filled():
                 incomplete_sport_list.append(sport)
 
         response = IncompleteSportSerializer(incomplete_sport_list)
 
-        return Response(response.data)
+        return paginator.get_paginated_response(response.data)
 
 
 class CriteriaView(APIView):
-- 
GitLab