mirror of
https://github.com/ansible/awx.git
synced 2026-02-26 15:36:04 -03:30
@@ -177,3 +177,10 @@ class Metadata(metadata.SimpleMetadata):
|
|||||||
metadata['search_fields'] = view.search_fields
|
metadata['search_fields'] = view.search_fields
|
||||||
|
|
||||||
return metadata
|
return metadata
|
||||||
|
|
||||||
|
class RoleMetadata(Metadata):
|
||||||
|
def determine_metadata(self, request, view):
|
||||||
|
metadata = super(RoleMetadata, self).determine_metadata(request, view)
|
||||||
|
if 'actions' in metadata:
|
||||||
|
metadata['actions'].pop('POST')
|
||||||
|
return metadata
|
||||||
|
|||||||
@@ -1446,7 +1446,8 @@ class RoleSerializer(BaseSerializer):
|
|||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Role
|
model = Role
|
||||||
fields = ('*',)
|
fields = ('*', 'description', 'name')
|
||||||
|
read_only_fields = ('description', 'name')
|
||||||
|
|
||||||
def get_related(self, obj):
|
def get_related(self, obj):
|
||||||
ret = super(RoleSerializer, self).get_related(obj)
|
ret = super(RoleSerializer, self).get_related(obj)
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ from awx.main.utils import * # noqa
|
|||||||
from awx.api.permissions import * # noqa
|
from awx.api.permissions import * # noqa
|
||||||
from awx.api.renderers import * # noqa
|
from awx.api.renderers import * # noqa
|
||||||
from awx.api.serializers import * # noqa
|
from awx.api.serializers import * # noqa
|
||||||
|
from awx.api.metadata import RoleMetadata
|
||||||
from awx.main.utils import emit_websocket_notification
|
from awx.main.utils import emit_websocket_notification
|
||||||
from awx.main.conf import tower_settings
|
from awx.main.conf import tower_settings
|
||||||
|
|
||||||
@@ -795,6 +796,7 @@ class TeamRolesList(SubListCreateAttachDetachAPIView):
|
|||||||
|
|
||||||
model = Role
|
model = Role
|
||||||
serializer_class = RoleSerializer
|
serializer_class = RoleSerializer
|
||||||
|
metadata_class = RoleMetadata
|
||||||
parent_model = Team
|
parent_model = Team
|
||||||
relationship='member_role.children'
|
relationship='member_role.children'
|
||||||
|
|
||||||
@@ -1075,6 +1077,7 @@ class UserRolesList(SubListCreateAttachDetachAPIView):
|
|||||||
|
|
||||||
model = Role
|
model = Role
|
||||||
serializer_class = RoleSerializer
|
serializer_class = RoleSerializer
|
||||||
|
metadata_class = RoleMetadata
|
||||||
parent_model = User
|
parent_model = User
|
||||||
relationship='roles'
|
relationship='roles'
|
||||||
permission_classes = (IsAuthenticated,)
|
permission_classes = (IsAuthenticated,)
|
||||||
|
|||||||
Reference in New Issue
Block a user