aboutsummaryrefslogtreecommitdiffstats
path: root/pydis_site/apps/api/viewsets
diff options
context:
space:
mode:
authorGravatar Kunal Sharma <[email protected]>2021-01-28 02:40:17 +0530
committerGravatar Kunal Sharma <[email protected]>2021-01-28 02:40:17 +0530
commitd1955b7a87fcd126b3c0a6b33ec2e7df6495b3de (patch)
tree785674eb418ab1fe37aa755898b04566d35ea0f2 /pydis_site/apps/api/viewsets
parentfix: flake8 error (diff)
update paginated response in list infraction
Diffstat (limited to 'pydis_site/apps/api/viewsets')
-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."""