fill in api browser with needed extra_vars passwords and credential

This commit is contained in:
Chris Meyers 2015-04-27 14:15:35 -04:00
parent 086ae8f9ad
commit 90037bbc2f

View File

@ -1706,6 +1706,17 @@ class JobLaunchSerializer(BaseSerializer):
read_only_fields = ('ask_variables_on_launch',)
write_only_fields = ('credential','extra_vars',)
def to_native(self, obj):
res = super(JobLaunchSerializer, self).to_native(obj)
view = self.context.get('view', None)
if hasattr(view, '_raw_data_form_marker'):
if obj.passwords_needed_to_start:
password_keys = dict([(p, u'') for p in obj.passwords_needed_to_start])
res.update(dict(extra_vars=password_keys))
if self.get_credential_needed_to_start(obj) is True:
res.update(dict(credential=''))
return res
def get_credential_needed_to_start(self, obj):
return not (obj and obj.credential and obj.credential.active)