From 259e48df3eb353f72aadf6880c9fa1eb140798ed Mon Sep 17 00:00:00 2001 From: Matthew Jones Date: Mon, 22 Sep 2014 11:10:33 -0400 Subject: [PATCH] Add survey bits to summary fields on job templates.... change "title" to "name" on survey metadata. --- awx/api/serializers.py | 6 ++++++ awx/main/models/jobs.py | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/awx/api/serializers.py b/awx/api/serializers.py index 92e314fb99..c2b97efb4a 100644 --- a/awx/api/serializers.py +++ b/awx/api/serializers.py @@ -1244,6 +1244,12 @@ class JobTemplateSerializer(UnifiedJobTemplateSerializer, JobOptionsSerializer): res['survey_spec'] = reverse('api:job_template_survey_spec', args=(obj.pk,)) return res + def get_summary_fields(self, obj): + d = super(JobTemplateSerializer, self).get_summary_fields(obj) + if obj.survey_enabled and ('name' in obj.survey_spec and 'description' in obj.survey_spec): + d['survey'] = dict(title=obj.survey_spec['name'], description=obj.survey_spec['description']) + return d + class JobSerializer(UnifiedJobSerializer, JobOptionsSerializer): diff --git a/awx/main/models/jobs.py b/awx/main/models/jobs.py index e30485be36..6e5bdf3a28 100644 --- a/awx/main/models/jobs.py +++ b/awx/main/models/jobs.py @@ -233,8 +233,8 @@ class JobTemplate(UnifiedJobTemplate, JobOptions): errors = [] if not self.survey_enabled: return errors - if 'title' not in self.survey_spec: - errors.append("'title' missing from survey spec") + if 'name' not in self.survey_spec: + errors.append("'name' missing from survey spec") if 'description' not in self.survey_spec: errors.append("'description' missing from survey spec") for survey_element in self.survey_spec["spec"]: