diff --git a/app/apps/decisions/views.py b/app/apps/decisions/views.py index 19c32a833..703594e8f 100644 --- a/app/apps/decisions/views.py +++ b/app/apps/decisions/views.py @@ -6,6 +6,7 @@ DecisionSerializer, DecisionTypeSerializer, ) +from apps.main.pagination import LimitedOffsetPaginator from apps.users.permissions import CanPerformTask, rest_permission_classes_for_top from django_filters.rest_framework import DjangoFilterBackend from drf_spectacular.utils import extend_schema @@ -24,6 +25,7 @@ class DecisionViewSet(GenericViewSet, CreateModelMixin, ListModelMixin): serializer_class = DecisionSerializer queryset = Decision.objects.all() filter_backends = [DjangoFilterBackend] + paginator_class = LimitedOffsetPaginator filterset_fields = { "case": [ "exact", diff --git a/app/apps/main/pagination.py b/app/apps/main/pagination.py index 958d56f83..c08ced36e 100644 --- a/app/apps/main/pagination.py +++ b/app/apps/main/pagination.py @@ -1,7 +1,7 @@ from collections import OrderedDict from rest_framework.exceptions import NotFound -from rest_framework.pagination import PageNumberPagination +from rest_framework.pagination import LimitOffsetPagination, PageNumberPagination from rest_framework.response import Response @@ -31,3 +31,7 @@ def get_paginated_response(self, data): ] ) ) + + +class LimitedOffsetPaginator(LimitOffsetPagination): + max_limit = 1000 diff --git a/app/apps/summons/views.py b/app/apps/summons/views.py index e7095ebd4..7d915233c 100644 --- a/app/apps/summons/views.py +++ b/app/apps/summons/views.py @@ -1,5 +1,6 @@ import logging +from apps.main.pagination import LimitedOffsetPaginator from apps.summons.models import Summon, SummonedPerson, SummonType from apps.summons.serializers import ( SummonedPersonAnonomizedSerializer, @@ -21,6 +22,7 @@ class SummonViewSet(GenericViewSet, CreateModelMixin, ListModelMixin): queryset = Summon.objects.all() filter_backends = [DjangoFilterBackend] filterset_fields = ["case"] + pagination_class = LimitedOffsetPaginator def get_permissions(self): if self.request.method not in SAFE_METHODS: diff --git a/app/apps/visits/views.py b/app/apps/visits/views.py index ff0063004..255127f76 100644 --- a/app/apps/visits/views.py +++ b/app/apps/visits/views.py @@ -1,3 +1,4 @@ +from apps.main.pagination import LimitedOffsetPaginator from apps.users.permissions import rest_permission_classes_for_top from rest_framework.mixins import CreateModelMixin, ListModelMixin from rest_framework.viewsets import GenericViewSet @@ -10,3 +11,4 @@ class VisitViewSet(GenericViewSet, CreateModelMixin, ListModelMixin): permission_classes = rest_permission_classes_for_top() serializer_class = VisitSerializer queryset = Visit.objects.all() + pagination_class = LimitedOffsetPaginator