diff options
-rw-r--r-- | pydis_site/apps/api/viewsets/bot/infraction.py | 15 | ||||
-rw-r--r-- | pydis_site/settings.py | 5 |
2 files changed, 17 insertions, 3 deletions
diff --git a/pydis_site/apps/api/viewsets/bot/infraction.py b/pydis_site/apps/api/viewsets/bot/infraction.py index 2ccb35dd..851eae34 100644 --- a/pydis_site/apps/api/viewsets/bot/infraction.py +++ b/pydis_site/apps/api/viewsets/bot/infraction.py @@ -133,6 +133,21 @@ class InfractionViewSet( filter_fields = ('user__id', 'actor__id', 'active', 'hidden', 'type') search_fields = ('$reason',) frozen_fields = ('id', 'inserted_at', 'type', 'user', 'actor', 'hidden') + LimitOffsetPagination.default_limit = 100 + + def list(self, request: HttpRequest, *args, **kwargs) -> Response: + """ + DRF method for listing Infraction entries. + + Called by the Django Rest Framework in response to the corresponding HTTP request. + """ + queryset = self.filter_queryset(self.get_queryset()) + page = self.paginate_queryset(queryset) + if page: + serializer = self.get_serializer(page, many=True) + return Response(self.get_paginated_response(serializer.data).data.get('results')) + serializer = InfractionSerializer(queryset, many=True) + return Response(serializer.data) def partial_update(self, request: HttpRequest, *_args, **_kwargs) -> Response: """Method that handles the nuts and bolts of updating an Infraction.""" diff --git a/pydis_site/settings.py b/pydis_site/settings.py index a98b5712..8f5c58ef 100644 --- a/pydis_site/settings.py +++ b/pydis_site/settings.py @@ -230,9 +230,8 @@ REST_FRAMEWORK = { 'DEFAULT_PERMISSION_CLASSES': ( 'rest_framework.permissions.DjangoModelPermissions', ), - 'TEST_REQUEST_DEFAULT_FORMAT': 'json', - 'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.LimitOffsetPagination', - 'PAGE_SIZE': 100, + 'TEST_REQUEST_DEFAULT_FORMAT': 'json' + } # Logging |