mirror of
https://github.com/ansible/awx.git
synced 2026-02-19 04:00:06 -03:30
fill in api browser with needed extra_vars passwords and credential
This commit is contained in:
@@ -1706,6 +1706,17 @@ class JobLaunchSerializer(BaseSerializer):
|
|||||||
read_only_fields = ('ask_variables_on_launch',)
|
read_only_fields = ('ask_variables_on_launch',)
|
||||||
write_only_fields = ('credential','extra_vars',)
|
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):
|
def get_credential_needed_to_start(self, obj):
|
||||||
return not (obj and obj.credential and obj.credential.active)
|
return not (obj and obj.credential and obj.credential.active)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user