Return template name in job response

If you’ve sent a bunch of jobs from the same contact list then a handy
way to differentiate between them will be date sent, but also template
name (in effect the message you sent).

This commit extends the job response to include template name, using the
same pattern as for template type.
This commit is contained in:
Chris Hill-Scott
2020-05-12 12:56:01 +01:00
parent 3ed1700231
commit c8cd3c2b70
2 changed files with 5 additions and 0 deletions

View File

@@ -380,9 +380,13 @@ class JobSchema(BaseSchema):
service_name = fields.Nested(
ServiceSchema, attribute="service", dump_to="service_name", only=["name"], dump_only=True)
template_name = fields.Method('get_template_name', dump_only=True)
template_type = fields.Method('get_template_type', dump_only=True)
contact_list_id = field_for(models.Job, 'contact_list_id')
def get_template_name(self, job):
return job.template.name
def get_template_type(self, job):
return job.template.template_type