mirror of
https://github.com/ansible/awx.git
synced 2026-05-08 01:47:35 -02:30
Switched /api/v1/roles/ to a cursor paginator so we don't have to do a count() on that potentially very large result set
This commit is contained in:
@@ -1443,8 +1443,13 @@ class RoleSerializer(BaseSerializer):
|
|||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Role
|
model = Role
|
||||||
fields = ('*', 'description', 'name')
|
read_only_fields = ('id', 'role_field', 'description', 'name')
|
||||||
read_only_fields = ('description', 'name')
|
|
||||||
|
def to_representation(self, obj):
|
||||||
|
ret = super(RoleSerializer, self).to_representation(obj)
|
||||||
|
ret.pop('created')
|
||||||
|
ret.pop('modified')
|
||||||
|
return ret
|
||||||
|
|
||||||
def get_related(self, obj):
|
def get_related(self, obj):
|
||||||
ret = super(RoleSerializer, self).get_related(obj)
|
ret = super(RoleSerializer, self).get_related(obj)
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ from rest_framework.permissions import AllowAny, IsAuthenticated
|
|||||||
from rest_framework.response import Response
|
from rest_framework.response import Response
|
||||||
from rest_framework.settings import api_settings
|
from rest_framework.settings import api_settings
|
||||||
from rest_framework.views import exception_handler
|
from rest_framework.views import exception_handler
|
||||||
|
from rest_framework.pagination import CursorPagination
|
||||||
from rest_framework import status
|
from rest_framework import status
|
||||||
|
|
||||||
# Django REST Framework YAML
|
# Django REST Framework YAML
|
||||||
@@ -3475,6 +3476,9 @@ class RoleList(ListAPIView):
|
|||||||
model = Role
|
model = Role
|
||||||
serializer_class = RoleSerializer
|
serializer_class = RoleSerializer
|
||||||
permission_classes = (IsAuthenticated,)
|
permission_classes = (IsAuthenticated,)
|
||||||
|
class CursorPaginationById(CursorPagination):
|
||||||
|
ordering = 'id'
|
||||||
|
pagination_class = CursorPaginationById
|
||||||
new_in_300 = True
|
new_in_300 = True
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user