From 2eeecb01a7e3c0b1939a659d2c75012cd466777f Mon Sep 17 00:00:00 2001 From: Chris Church Date: Mon, 31 Mar 2014 11:33:29 -0400 Subject: [PATCH] AC-1040 Updated type choice names for unified job subclasses. --- awx/api/generics.py | 5 +---- awx/api/serializers.py | 14 +++++++++++++- 2 files changed, 14 insertions(+), 5 deletions(-) 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 ''