mirror of
https://github.com/ansible/awx.git
synced 2026-03-02 09:18:48 -03:30
Merge pull request #2185 from ryanpetrello/fix-2184
fix a bug in JobTemplate.extra_credentials summary_fields
This commit is contained in:
@@ -3034,6 +3034,10 @@ class JobTemplateSerializer(JobTemplateMixin, UnifiedJobTemplateSerializer, JobO
|
|||||||
def get_summary_fields(self, obj):
|
def get_summary_fields(self, obj):
|
||||||
summary_fields = super(JobTemplateSerializer, self).get_summary_fields(obj)
|
summary_fields = super(JobTemplateSerializer, self).get_summary_fields(obj)
|
||||||
all_creds = []
|
all_creds = []
|
||||||
|
# Organize credential data into multitude of deprecated fields
|
||||||
|
vault_credential = None
|
||||||
|
credential = None
|
||||||
|
extra_creds = []
|
||||||
if obj.pk:
|
if obj.pk:
|
||||||
for cred in obj.credentials.all():
|
for cred in obj.credentials.all():
|
||||||
summarized_cred = {
|
summarized_cred = {
|
||||||
@@ -3044,17 +3048,12 @@ class JobTemplateSerializer(JobTemplateMixin, UnifiedJobTemplateSerializer, JobO
|
|||||||
'credential_type_id': cred.credential_type_id
|
'credential_type_id': cred.credential_type_id
|
||||||
}
|
}
|
||||||
all_creds.append(summarized_cred)
|
all_creds.append(summarized_cred)
|
||||||
# Organize credential data into multitude of deprecated fields
|
if cred.credential_type.kind in ('cloud', 'net'):
|
||||||
extra_creds = []
|
extra_creds.append(summarized_cred)
|
||||||
vault_credential = None
|
elif summarized_cred['kind'] == 'ssh':
|
||||||
credential = None
|
credential = summarized_cred
|
||||||
for summarized_cred in all_creds:
|
elif summarized_cred['kind'] == 'vault':
|
||||||
if summarized_cred['kind'] in ('cloud', 'net'):
|
vault_credential = summarized_cred
|
||||||
extra_creds.append(summarized_cred)
|
|
||||||
elif summarized_cred['kind'] == 'ssh':
|
|
||||||
credential = summarized_cred
|
|
||||||
elif summarized_cred['kind'] == 'vault':
|
|
||||||
vault_credential = summarized_cred
|
|
||||||
# Selectively apply those fields, depending on view deetails
|
# Selectively apply those fields, depending on view deetails
|
||||||
if (self.is_detail_view or self.version == 1) and credential:
|
if (self.is_detail_view or self.version == 1) and credential:
|
||||||
summary_fields['credential'] = credential
|
summary_fields['credential'] = credential
|
||||||
|
|||||||
Reference in New Issue
Block a user