mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-05 02:41:14 -05:00
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:
@@ -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):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user