From 67b2937123df6568767af138ee39f95d571d666d Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Mon, 19 Jun 2017 14:32:21 +0100 Subject: [PATCH] Show full message content on notification page MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- app/main/views/notifications.py | 26 ++++++++++++---------- tests/app/main/views/test_notifications.py | 2 +- tests/conftest.py | 3 ++- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/app/main/views/notifications.py b/app/main/views/notifications.py index f7af4bdf4..f7351249f 100644 --- a/app/main/views/notifications.py +++ b/app/main/views/notifications.py @@ -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, diff --git a/tests/app/main/views/test_notifications.py b/tests/app/main/views/test_notifications.py index 7decfcd80..10cfa2485 100644 --- a/tests/app/main/views/test_notifications.py +++ b/tests/app/main/views/test_notifications.py @@ -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 diff --git a/tests/conftest.py b/tests/conftest.py index 7f556c22d..d4c1f6754 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -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(