mirror of
https://github.com/ansible/awx.git
synced 2026-03-05 18:51:06 -03:30
Merge pull request #733 from AlanCoding/credentials_in_list
Show credentials in list view
This commit is contained in:
@@ -2545,9 +2545,9 @@ 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)
|
||||||
if self.is_detail_view:
|
all_creds = []
|
||||||
all_creds = []
|
extra_creds = []
|
||||||
extra_creds = []
|
if obj.pk:
|
||||||
for cred in obj.credentials.all():
|
for cred in obj.credentials.all():
|
||||||
summarized_cred = {
|
summarized_cred = {
|
||||||
'id': cred.pk,
|
'id': cred.pk,
|
||||||
@@ -2557,15 +2557,21 @@ 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)
|
||||||
if cred.credential_type.kind in ('cloud', 'net'):
|
if self.is_detail_view:
|
||||||
|
for summarized_cred in all_creds:
|
||||||
|
if summarized_cred['kind'] in ('cloud', 'net'):
|
||||||
extra_creds.append(summarized_cred)
|
extra_creds.append(summarized_cred)
|
||||||
elif cred.credential_type.kind == 'ssh':
|
elif summarized_cred['kind'] == 'ssh':
|
||||||
summary_fields['credential'] = summarized_cred
|
summary_fields['credential'] = summarized_cred
|
||||||
elif cred.credential_type.kind == 'vault':
|
elif summarized_cred['kind'] == 'vault':
|
||||||
summary_fields['vault_credential'] = summarized_cred
|
summary_fields['vault_credential'] = summarized_cred
|
||||||
if self.version > 1:
|
if self.version > 1:
|
||||||
|
if self.is_detail_view:
|
||||||
summary_fields['extra_credentials'] = extra_creds
|
summary_fields['extra_credentials'] = extra_creds
|
||||||
summary_fields['credentials'] = all_creds
|
else:
|
||||||
|
# Credential would be an empty dictionary in this case
|
||||||
|
summary_fields.pop('credential', None)
|
||||||
|
summary_fields['credentials'] = all_creds
|
||||||
return summary_fields
|
return summary_fields
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user