Serialise content for broadcast templates

Broadcast services only have broadcast templates. But on the frontend
we show the template type under the name of the template. This is
redundant. It would be better to preview the content of the template
instead.

At the moment we can’t do this because we optimised the template schema
response to not include the content of the templates in
https://github.com/alphagov/notifications-api/pull/2880

This commit reverses that optimisation, for broadcast templates only,
and expands the tests to cover all template types.
This commit is contained in:
Chris Hill-Scott
2020-10-13 16:08:33 +01:00
parent 50982ff36a
commit 3a2081dc06
2 changed files with 22 additions and 3 deletions

View File

@@ -377,7 +377,6 @@ class TemplateSchemaNoDetail(TemplateSchema):
class Meta(TemplateSchema.Meta):
exclude = TemplateSchema.Meta.exclude + (
'archived',
'content',
'created_at',
'created_by',
'created_by_id',
@@ -396,6 +395,11 @@ class TemplateSchemaNoDetail(TemplateSchema):
'broadcast_data',
)
@pre_dump
def remove_content_for_non_broadcast_templates(self, template):
if template.template_type != models.BROADCAST_TYPE:
template.content = None
class TemplateHistorySchema(BaseSchema):