Show full message content on notification page

We’ve had a few teams talk about wanting to go back and check what their
users are sending out, including the content of any placeholders.

We already provide this functionality through the API, this commit makes
it the default in the admin app too.

We couldn’t do this before because we didn’t have the individual
notification page.

It’s better to do this by re-hydrating the template than pulling the
content from the API, because things like letters have multiple areas
of content – this is more complex than what we can get from API at the
moment.
This commit is contained in:
Chris Hill-Scott
2017-06-19 14:32:21 +01:00
parent 5e4aff2a7b
commit 67b2937123
3 changed files with 17 additions and 14 deletions

View File

@@ -44,22 +44,24 @@ def get_status_arg(filter_args):
@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)
template = get_template(
notification['template'],
current_service,
letter_preview_url=url_for(
'.view_template_version_preview',
service_id=service_id,
template_id=notification['template']['id'],
version=notification['template_version'],
filetype='png',
),
show_recipient=True,
)
template.values = notification['personalisation']
return render_template(
'views/notifications/notification.html',
finished=(notification['status'] in (DELIVERED_STATUSES + FAILURE_STATUSES)),
uploaded_file_name='Report',
template=get_template(
notification['template'],
current_service,
letter_preview_url=url_for(
'.view_template_version_preview',
service_id=service_id,
template_id=notification['template']['id'],
version=notification['template_version'],
filetype='png',
),
show_recipient=True,
),
template=template,
updates_url=url_for(
".view_notification_updates",
service_id=service_id,

View File

@@ -44,7 +44,7 @@ def test_notification_status_page_shows_details(
)
assert normalize_spaces(page.select('.sms-message-wrapper')[0].text) == (
'service one: template content'
'service one: hello Jo'
)
assert normalize_spaces(page.select('.ajax-block-container p')[0].text) == (
expected_status

View File

@@ -1635,7 +1635,8 @@ def mock_get_notification(mocker, fake_uuid, notification_status='delivered'):
'name': 'Test User',
'email_address': 'test@user.gov.uk'
}
noti['template'] = template_json(service_id, str(generate_uuid()))
noti['personalisation'] = {'name': 'Jo'}
noti['template'] = template_json(service_id, str(generate_uuid()), content='hello ((name))')
return noti
return mocker.patch(