Skip to content
Snippets Groups Projects
Commit 89a61198 authored by borzechof99's avatar borzechof99 :whale2:
Browse files

Add Pagination to Archive

parent 0f918597
No related branches found
No related tags found
No related merge requests found
...@@ -551,7 +551,7 @@ class APITest(APITestCase): ...@@ -551,7 +551,7 @@ class APITest(APITestCase):
# Get initial State of Archive # Get initial State of Archive
response = self.client.get(reverse("archive")) response = self.client.get(reverse("archive"))
self.assertEqual(response.data, []) self.assertEqual(response.data["results"], [])
# Change State of Sport # Change State of Sport
response = self.client.patch( response = self.client.patch(
...@@ -563,8 +563,8 @@ class APITest(APITestCase): ...@@ -563,8 +563,8 @@ class APITest(APITestCase):
# Check whether the Archive changed # Check whether the Archive changed
response = self.client.get(reverse("archive")) response = self.client.get(reverse("archive"))
self.assertEqual(response.data[0]["id"], 1) self.assertEqual(response.data["results"][0]["id"], 1)
self.assertEqual(response.data[0]["name"], "Jiu Jitsu") self.assertEqual(response.data["results"][0]["name"], "Jiu Jitsu")
def test_sport_scraper(self): def test_sport_scraper(self):
""" """
...@@ -591,4 +591,4 @@ class APITest(APITestCase): ...@@ -591,4 +591,4 @@ class APITest(APITestCase):
self.assertEqual(len(sport_response.data["results"]), 120) self.assertEqual(len(sport_response.data["results"]), 120)
sport_response = self.client.get(reverse("archive")) sport_response = self.client.get(reverse("archive"))
self.assertEqual(len(sport_response.data), 1) self.assertEqual(len(sport_response.data["results"]), 1)
...@@ -295,11 +295,15 @@ class SportArchiveView(APIView): ...@@ -295,11 +295,15 @@ class SportArchiveView(APIView):
GET for api/admin/archive/ GET for api/admin/archive/
""" """
archived_sports = Sport.objects.filter(currently_active=False) paginator = PageNumberWithPageSizePagination()
archived_sports = paginator.paginate_queryset(
Sport.objects.filter(currently_active=False).order_by("name"), request
)
response = ArchiveSerializer(archived_sports) response = ArchiveSerializer(archived_sports)
return Response(response.data) return paginator.get_paginated_response(response.data)
class ScraperView(APIView): class ScraperView(APIView):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment