diff --git a/awx/api/generics.py b/awx/api/generics.py index b9639215fb..bec44988cc 100644 --- a/awx/api/generics.py +++ b/awx/api/generics.py @@ -201,10 +201,7 @@ class GenericAPIView(generics.GenericAPIView, APIView): # the metadata itself. if 'type' in actions['GET']: actions['GET']['type']['type'] = 'multiple choice' - actions['GET']['type']['choices'] = [ - (x, unicode(get_model_for_type(x)._meta.verbose_name)) - for x in serializer.get_types() - ] + actions['GET']['type']['choices'] = serializer.get_type_choices() ret['types'] = serializer.get_types() if actions: ret['actions'] = actions diff --git a/awx/api/serializers.py b/awx/api/serializers.py index a315a1f481..c104e1c0c3 100644 --- a/awx/api/serializers.py +++ b/awx/api/serializers.py @@ -30,7 +30,7 @@ from rest_framework import serializers # AWX from awx.main.models import * -from awx.main.utils import update_scm_url, get_type_for_model +from awx.main.utils import update_scm_url, get_type_for_model, get_model_for_type logger = logging.getLogger('awx.api.serializers') @@ -219,6 +219,18 @@ class BaseSerializer(serializers.ModelSerializer): def get_types(self): return [self.get_type(None)] + def get_type_choices(self): + type_name_map = { + 'job': 'playbook run', + 'project_update': 'project sync', + 'inventory_update': 'inventory sync', + } + choices = [] + for t in self.get_types(): + name = type_name_map.get(t, unicode(get_model_for_type(t)._meta.verbose_name)) + choices.append((t, name)) + return choices + def get_url(self, obj): if obj is None: return ''