Merge pull request #1897 from normanjaeckel/PermDisplayName
Changed display name of permissions in GroupViewSet. Fixed #1895.
This commit is contained in:
commit
23ad11d232
@ -8,6 +8,7 @@ from ..core.config import config
|
|||||||
from ..utils.rest_api import (
|
from ..utils.rest_api import (
|
||||||
ModelViewSet,
|
ModelViewSet,
|
||||||
Response,
|
Response,
|
||||||
|
SimpleMetadata,
|
||||||
ValidationError,
|
ValidationError,
|
||||||
detail_route,
|
detail_route,
|
||||||
status,
|
status,
|
||||||
@ -163,6 +164,21 @@ class UserViewSet(ModelViewSet):
|
|||||||
return Response({'detail': _('Password successfully reset.')})
|
return Response({'detail': _('Password successfully reset.')})
|
||||||
|
|
||||||
|
|
||||||
|
class GroupViewSetMetadata(SimpleMetadata):
|
||||||
|
"""
|
||||||
|
Customized metadata class for OPTIONS requests.
|
||||||
|
"""
|
||||||
|
def get_field_info(self, field):
|
||||||
|
"""
|
||||||
|
Customized method to change the display name of permission choices.
|
||||||
|
"""
|
||||||
|
field_info = super().get_field_info(field)
|
||||||
|
if field.field_name == 'permissions':
|
||||||
|
for choice in field_info['choices']:
|
||||||
|
choice['display_name'] = choice['display_name'].split(' | ')[2]
|
||||||
|
return field_info
|
||||||
|
|
||||||
|
|
||||||
class GroupViewSet(ModelViewSet):
|
class GroupViewSet(ModelViewSet):
|
||||||
"""
|
"""
|
||||||
API endpoint for groups.
|
API endpoint for groups.
|
||||||
@ -170,6 +186,7 @@ class GroupViewSet(ModelViewSet):
|
|||||||
There are the following views: metadata, list, retrieve, create,
|
There are the following views: metadata, list, retrieve, create,
|
||||||
partial_update, update and destroy.
|
partial_update, update and destroy.
|
||||||
"""
|
"""
|
||||||
|
metadata_class = GroupViewSetMetadata
|
||||||
queryset = Group.objects.all()
|
queryset = Group.objects.all()
|
||||||
serializer_class = GroupSerializer
|
serializer_class = GroupSerializer
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user