mirror of
https://github.com/ansible/awx.git
synced 2024-11-01 16:51:11 +03:00
prefetch UnifiedJob related credentials
This commit is contained in:
parent
d6b10b7f44
commit
8cb5ce8307
@ -1939,6 +1939,7 @@ class UnifiedJobTemplateAccess(BaseAccess):
|
||||
prefetch_related = (
|
||||
'last_job',
|
||||
'current_job',
|
||||
'credentials__credential_type',
|
||||
Prefetch('labels', queryset=Label.objects.all().order_by('name')),
|
||||
)
|
||||
|
||||
@ -1982,6 +1983,7 @@ class UnifiedJobAccess(BaseAccess):
|
||||
'unified_job_node__workflow_job',
|
||||
'unified_job_template',
|
||||
'instance_group',
|
||||
'credentials__credential_type',
|
||||
Prefetch('labels', queryset=Label.objects.all().order_by('name')),
|
||||
)
|
||||
|
||||
|
@ -185,9 +185,10 @@ class JobOptions(BaseModel):
|
||||
return cred.pk
|
||||
|
||||
def get_deprecated_credential(self, kind):
|
||||
try:
|
||||
return self.credentials.filter(credential_type__kind=kind).first()
|
||||
except IndexError:
|
||||
for cred in self.credentials.all():
|
||||
if cred.credential_type.kind == kind:
|
||||
return cred
|
||||
else:
|
||||
return None
|
||||
|
||||
# TODO: remove when API v1 is removed
|
||||
|
Loading…
Reference in New Issue
Block a user