diff --git a/awx/api/metadata.py b/awx/api/metadata.py index f5c72fed97..7391fece6b 100644 --- a/awx/api/metadata.py +++ b/awx/api/metadata.py @@ -177,3 +177,10 @@ class Metadata(metadata.SimpleMetadata): metadata['search_fields'] = view.search_fields 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 diff --git a/awx/api/serializers.py b/awx/api/serializers.py index 89fda89a55..490697db5c 100644 --- a/awx/api/serializers.py +++ b/awx/api/serializers.py @@ -1446,7 +1446,8 @@ class RoleSerializer(BaseSerializer): class Meta: model = Role - fields = ('*',) + fields = ('*', 'description', 'name') + read_only_fields = ('description', 'name') def get_related(self, obj): ret = super(RoleSerializer, self).get_related(obj) diff --git a/awx/api/views.py b/awx/api/views.py index 5daf08ac5c..85f71d2cdf 100644 --- a/awx/api/views.py +++ b/awx/api/views.py @@ -67,6 +67,7 @@ from awx.main.utils import * # noqa from awx.api.permissions import * # noqa from awx.api.renderers 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.conf import tower_settings @@ -795,6 +796,7 @@ class TeamRolesList(SubListCreateAttachDetachAPIView): model = Role serializer_class = RoleSerializer + metadata_class = RoleMetadata parent_model = Team relationship='member_role.children' @@ -1075,6 +1077,7 @@ class UserRolesList(SubListCreateAttachDetachAPIView): model = Role serializer_class = RoleSerializer + metadata_class = RoleMetadata parent_model = User relationship='roles' permission_classes = (IsAuthenticated,)