refactor the job type name into a single property

This commit is contained in:
Ryan Petrello
2020-07-13 09:43:43 -04:00
parent f51774c06e
commit ab11d3188d
3 changed files with 35 additions and 4 deletions

View File

@@ -1697,7 +1697,7 @@ class HostSerializer(BaseSerializerWithVariables):
d.setdefault('recent_jobs', [{
'id': j.job.id,
'name': j.job.job_template.name if j.job.job_template is not None else "",
'type': j.job.get_real_instance_class()._meta.verbose_name.replace(' ', '_'),
'type': j.job.job_type_name,
'status': j.job.status,
'finished': j.job.finished,
} for j in obj.job_host_summaries.select_related('job__job_template').order_by('-created')[:5]])
@@ -2842,7 +2842,7 @@ class JobTemplateMixin(object):
return [{
'id': x.id, 'status': x.status, 'finished': x.finished, 'canceled_on': x.canceled_on,
# Make type consistent with API top-level key, for instance workflow_job
'type': x.get_real_instance_class()._meta.verbose_name.replace(' ', '_')
'type': x.job_type_name
} for x in optimized_qs[:10]]
def get_summary_fields(self, obj):