mirror of
https://github.com/ansible/awx.git
synced 2024-11-02 09:51:09 +03:00
AC-1040 Updated type choice names for unified job subclasses.
This commit is contained in:
parent
96a4752f2f
commit
2eeecb01a7
@ -201,10 +201,7 @@ class GenericAPIView(generics.GenericAPIView, APIView):
|
|||||||
# the metadata itself.
|
# the metadata itself.
|
||||||
if 'type' in actions['GET']:
|
if 'type' in actions['GET']:
|
||||||
actions['GET']['type']['type'] = 'multiple choice'
|
actions['GET']['type']['type'] = 'multiple choice'
|
||||||
actions['GET']['type']['choices'] = [
|
actions['GET']['type']['choices'] = serializer.get_type_choices()
|
||||||
(x, unicode(get_model_for_type(x)._meta.verbose_name))
|
|
||||||
for x in serializer.get_types()
|
|
||||||
]
|
|
||||||
ret['types'] = serializer.get_types()
|
ret['types'] = serializer.get_types()
|
||||||
if actions:
|
if actions:
|
||||||
ret['actions'] = actions
|
ret['actions'] = actions
|
||||||
|
@ -30,7 +30,7 @@ from rest_framework import serializers
|
|||||||
|
|
||||||
# AWX
|
# AWX
|
||||||
from awx.main.models import *
|
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')
|
logger = logging.getLogger('awx.api.serializers')
|
||||||
|
|
||||||
@ -219,6 +219,18 @@ class BaseSerializer(serializers.ModelSerializer):
|
|||||||
def get_types(self):
|
def get_types(self):
|
||||||
return [self.get_type(None)]
|
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):
|
def get_url(self, obj):
|
||||||
if obj is None:
|
if obj is None:
|
||||||
return ''
|
return ''
|
||||||
|
Loading…
Reference in New Issue
Block a user