mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-18 21:49:37 -04:00
Merge pull request #1439 from alphagov/dvla-endpoint
Add platform–admin-only page to preview DVLA code
This commit is contained in:
@@ -9,12 +9,14 @@ from flask import (
|
||||
flash,
|
||||
abort,
|
||||
json,
|
||||
Response,
|
||||
)
|
||||
from flask_login import login_required, current_user
|
||||
from dateutil.parser import parse
|
||||
|
||||
from notifications_utils.formatters import escape_html
|
||||
from notifications_utils.recipients import first_column_headings
|
||||
from notifications_utils.template import LetterDVLATemplate
|
||||
from notifications_python_client.errors import HTTPError
|
||||
|
||||
from app.main import main
|
||||
@@ -146,6 +148,25 @@ def choose_template(service_id, template_type='all'):
|
||||
)
|
||||
|
||||
|
||||
@main.route("/services/<service_id>/templates/<template_id>/as-dvla")
|
||||
@login_required
|
||||
@user_has_permissions(admin_override=True)
|
||||
def view_template_as_dvla_markup(service_id, template_id):
|
||||
|
||||
template = service_api_client.get_service_template(service_id, str(template_id))['data']
|
||||
|
||||
if template['template_type'] != 'letter':
|
||||
abort(404)
|
||||
|
||||
return Response(
|
||||
str(LetterDVLATemplate(
|
||||
template,
|
||||
notification_reference=1,
|
||||
)).replace('<cr>', '<cr>\n'),
|
||||
mimetype='text/plain',
|
||||
)
|
||||
|
||||
|
||||
@main.route("/services/<service_id>/templates/<template_id>.<filetype>")
|
||||
@login_required
|
||||
@user_has_permissions('view_activity', admin_override=True)
|
||||
|
||||
Reference in New Issue
Block a user