mirror of
https://github.com/ansible/awx.git
synced 2026-01-12 18:40:01 -03:30
Merge pull request #733 from AlanCoding/credentials_in_list
Show credentials in list view
This commit is contained in:
commit
5602b5d2d7
@ -2545,9 +2545,9 @@ class JobTemplateSerializer(JobTemplateMixin, UnifiedJobTemplateSerializer, JobO
|
||||
|
||||
def get_summary_fields(self, obj):
|
||||
summary_fields = super(JobTemplateSerializer, self).get_summary_fields(obj)
|
||||
if self.is_detail_view:
|
||||
all_creds = []
|
||||
extra_creds = []
|
||||
all_creds = []
|
||||
extra_creds = []
|
||||
if obj.pk:
|
||||
for cred in obj.credentials.all():
|
||||
summarized_cred = {
|
||||
'id': cred.pk,
|
||||
@ -2557,15 +2557,21 @@ class JobTemplateSerializer(JobTemplateMixin, UnifiedJobTemplateSerializer, JobO
|
||||
'credential_type_id': cred.credential_type_id
|
||||
}
|
||||
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)
|
||||
elif cred.credential_type.kind == 'ssh':
|
||||
elif summarized_cred['kind'] == 'ssh':
|
||||
summary_fields['credential'] = summarized_cred
|
||||
elif cred.credential_type.kind == 'vault':
|
||||
elif summarized_cred['kind'] == 'vault':
|
||||
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['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
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user