Show personalisation in individual letters

Adds a new endpoint that works like view template/view preview of
letter, so that this page works the same way it does for emails/text
messages (ie showing the full content of the message, including
personalisation).

We’re not worrying about redaction in letters for now.
This commit is contained in:
Chris Hill-Scott
2017-07-13 13:28:11 +01:00
parent 63e9ef44e7
commit 68078041dd
3 changed files with 55 additions and 6 deletions

View File

@@ -14,6 +14,7 @@ from app import (
current_service
)
from app.main import main
from app.template_previews import TemplatePreview
from app.utils import (
user_has_permissions,
get_help_argument,
@@ -41,20 +42,18 @@ def get_status_arg(filter_args):
return REQUESTED_STATUSES
@main.route("/services/<service_id>/notification/<notification_id>")
@main.route("/services/<service_id>/notification/<uuid:notification_id>")
@login_required
@user_has_permissions('view_activity', admin_override=True)
def view_notification(service_id, notification_id):
notification = notification_api_client.get_notification(service_id, notification_id)
notification = notification_api_client.get_notification(service_id, str(notification_id))
template = get_template(
notification['template'],
current_service,
letter_preview_url=url_for(
'.view_template_version_preview',
'.view_letter_notification_as_image',
service_id=service_id,
template_id=notification['template']['id'],
version=notification['template_version'],
filetype='png',
notification_id=notification_id,
),
show_recipient=True,
redact_missing_personalisation=True,
@@ -86,6 +85,28 @@ def view_notification(service_id, notification_id):
)
@main.route("/services/<service_id>/notification/<uuid:notification_id>.png")
@login_required
@user_has_permissions('view_activity', admin_override=True)
def view_letter_notification_as_image(service_id, notification_id):
notification = notification_api_client.get_notification(service_id, notification_id)
template = get_template(
notification['template'],
current_service,
letter_preview_url=url_for(
'.view_letter_notification_as_image',
service_id=service_id,
notification_id=notification_id,
),
)
template.values = notification['personalisation']
return TemplatePreview.from_utils_template(template, 'png', page=request.args.get('page'))
@main.route("/services/<service_id>/notification/<notification_id>.json")
@user_has_permissions('view_activity', admin_override=True)
def view_notification_updates(service_id, notification_id):