1
0
mirror of https://github.com/ansible/awx.git synced 2024-10-31 23:51:09 +03:00

add customer API doc fixes:#1390

This commit is contained in:
Wayne Witzel III 2016-04-04 12:06:13 -04:00
parent 75a69d7c83
commit 554d8ed8a6
3 changed files with 12 additions and 1 deletions

View File

@ -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

View File

@ -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)

View File

@ -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,)