aboutsummaryrefslogtreecommitdiffstats
path: root/pydis_site/apps/api
diff options
context:
space:
mode:
Diffstat (limited to 'pydis_site/apps/api')
-rw-r--r--pydis_site/apps/api/viewsets/bot/infraction.py15
1 files changed, 15 insertions, 0 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."""