mirror of
https://github.com/GSA/notifications-api.git
synced 2026-07-30 03:08:32 -04:00
add redact to notification with template schema.
So that when the admin gets notifications, the template they return also has a "redact_personalisation" boolean attached to it. Note, it won't do the redacting on the api - that'll be part of the admin. Under the hood, this uses an association_proxy, which is essentially black magic. But it proxies the `redact_personalisation` property of `TemplateRedacted` onto the `Template` object, so that Marshmallow can pick it up. Note: NOT currently added to NotificationWithTemplateHistory
This commit is contained in:
@@ -443,6 +443,8 @@ class Template(db.Model):
|
||||
default=NORMAL
|
||||
)
|
||||
|
||||
redact_personalisation = association_proxy('template_redacted', 'redact_personalisation')
|
||||
|
||||
def get_link(self):
|
||||
# TODO: use "/v2/" route once available
|
||||
return url_for(
|
||||
|
||||
@@ -297,6 +297,11 @@ class BaseTemplateSchema(BaseSchema):
|
||||
strict = True
|
||||
|
||||
|
||||
class TemplateRedactedSchema(BaseSchema):
|
||||
class Meta:
|
||||
model = models.TemplateRedacted
|
||||
|
||||
|
||||
class TemplateSchema(BaseTemplateSchema):
|
||||
|
||||
created_by = field_for(models.Template, 'created_by', required=True)
|
||||
@@ -440,7 +445,7 @@ class NotificationWithTemplateSchema(BaseSchema):
|
||||
|
||||
template = fields.Nested(
|
||||
TemplateSchema,
|
||||
only=['id', 'version', 'name', 'template_type', 'content', 'subject'],
|
||||
only=['id', 'version', 'name', 'template_type', 'content', 'subject', 'redact_personalisation'],
|
||||
dump_only=True
|
||||
)
|
||||
job = fields.Nested(JobSchema, only=["id", "original_file_name"], dump_only=True)
|
||||
|
||||
Reference in New Issue
Block a user