Return template type for jobs

This is so we can display letter jobs in a different way on the admin
app (because it doesn’t make sense for them to have failed/delivered
counts like it does for email and text message jobs).

As elsewhere we use `fields.Method` to avoid serializing the whole
template object.
This commit is contained in:
Chris Hill-Scott
2020-02-25 16:05:39 +00:00
parent 3739d6f407
commit 8601b13595
2 changed files with 29 additions and 0 deletions

View File

@@ -380,6 +380,11 @@ class JobSchema(BaseSchema):
service_name = fields.Nested(
ServiceSchema, attribute="service", dump_to="service_name", only=["name"], dump_only=True)
template_type = fields.Method('get_template_type', dump_only=True)
def get_template_type(self, job):
return job.template.template_type
@validates('scheduled_for')
def validate_scheduled_for(self, value):
_validate_datetime_not_in_past(value)