Fix some invalid assumptions about hosts and jobs where we assume a job

template will always be available
This commit is contained in:
Matthew Jones 2014-06-23 13:39:09 -04:00
parent 788cf2e24e
commit 8d78755ef4
2 changed files with 6 additions and 2 deletions

View File

@ -756,7 +756,11 @@ class HostSerializer(BaseSerializerWithVariables):
d['last_job']['job_template_name'] = obj.last_job.job_template.name
except (KeyError, AttributeError):
pass
d.update({'recent_jobs': [{'id': j.job.id, 'name': j.job.job_template.name, 'status': j.job.status,
if j.job.job_template is not None:
job_template_name = j.job.job_template.name
else:
job_template_name = ""
d.update({'recent_jobs': [{'id': j.job.id, 'name': job_template_name, 'status': j.job.status,
'finished': j.job.finished} for j in obj.job_host_summaries.all().order_by('-created')[:5]]})
return d

View File

@ -259,7 +259,7 @@ class Job(UnifiedJob, JobOptions):
def is_blocked_by(self, obj):
from awx.main.models import InventoryUpdate, ProjectUpdate
if type(obj) == Job:
if obj.job_template == self.job_template:
if obj.job_template is not None and obj.job_template == self.job_template:
if obj.launch_type == 'callback' and self.launch_type == 'callback':
if obj.limit != self.limit:
return False