mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-24 08:16:51 -04:00
Merge branch 'master' into add_proxy_header_check
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from flask import (
|
||||
abort,
|
||||
render_template,
|
||||
jsonify,
|
||||
request,
|
||||
@@ -34,9 +35,10 @@ def view_notification(service_id, notification_id):
|
||||
notification['template'],
|
||||
current_service,
|
||||
letter_preview_url=url_for(
|
||||
'.view_letter_notification_as_image',
|
||||
'.view_letter_notification_as_preview',
|
||||
service_id=service_id,
|
||||
notification_id=notification_id,
|
||||
filetype='png',
|
||||
),
|
||||
show_recipient=True,
|
||||
redact_missing_personalisation=True,
|
||||
@@ -70,10 +72,13 @@ def view_notification(service_id, notification_id):
|
||||
)
|
||||
|
||||
|
||||
@main.route("/services/<service_id>/notification/<uuid:notification_id>.png")
|
||||
@main.route("/services/<service_id>/notification/<uuid:notification_id>.<filetype>")
|
||||
@login_required
|
||||
@user_has_permissions('view_activity', admin_override=True)
|
||||
def view_letter_notification_as_image(service_id, notification_id):
|
||||
def view_letter_notification_as_preview(service_id, notification_id, filetype):
|
||||
|
||||
if filetype not in ('pdf', 'png'):
|
||||
abort(404)
|
||||
|
||||
notification = notification_api_client.get_notification(service_id, notification_id)
|
||||
|
||||
@@ -81,15 +86,16 @@ def view_letter_notification_as_image(service_id, notification_id):
|
||||
notification['template'],
|
||||
current_service,
|
||||
letter_preview_url=url_for(
|
||||
'.view_letter_notification_as_image',
|
||||
'.view_letter_notification_as_preview',
|
||||
service_id=service_id,
|
||||
notification_id=notification_id,
|
||||
filetype='png',
|
||||
),
|
||||
)
|
||||
|
||||
template.values = notification['personalisation']
|
||||
|
||||
return TemplatePreview.from_utils_template(template, 'png', page=request.args.get('page'))
|
||||
return TemplatePreview.from_utils_template(template, filetype, page=request.args.get('page'))
|
||||
|
||||
|
||||
@main.route("/services/<service_id>/notification/<notification_id>.json")
|
||||
|
||||
@@ -48,7 +48,10 @@
|
||||
{% elif not recipients.has_recipient_columns %}
|
||||
|
||||
<h1 class='banner-title' data-module="track-error" data-error-type="Missing recipient columns" data-error-label="{{ upload_id }}">
|
||||
Your file needs {{ required_recipient_columns | formatted_list(
|
||||
Your file needs {{ (
|
||||
recipients.missing_column_headers
|
||||
if template.template_type == 'letter' else required_recipient_columns
|
||||
) | formatted_list(
|
||||
prefix='a column called',
|
||||
prefix_plural='columns called'
|
||||
) }}
|
||||
|
||||
@@ -34,6 +34,9 @@
|
||||
<p>
|
||||
Estimated delivery date: {{ estimated_letter_delivery_date|string|format_date_short }}
|
||||
</p>
|
||||
<p class="bottom-gutter">
|
||||
<a href="{{ url_for('main.view_letter_notification_as_preview', service_id=current_service.id, notification_id=notification_id, filetype='pdf') }}" download="download">Download as a PDF</a>
|
||||
</p>
|
||||
{% endif %}
|
||||
|
||||
{{ template|string }}
|
||||
|
||||
Reference in New Issue
Block a user