Merge pull request #2442 from alphagov/show-all-pages-notification

Show all letter pages on the notification page
This commit is contained in:
Chris Hill-Scott
2018-11-02 14:35:39 +00:00
committed by GitHub
2 changed files with 9 additions and 3 deletions

View File

@@ -48,11 +48,13 @@ def view_notification(service_id, notification_id):
notification = notification_api_client.get_notification(service_id, str(notification_id))
notification['template'].update({'reply_to_text': notification['reply_to_text']})
personalisation = get_all_personalisation_from_notification(notification)
if notification['template']['is_precompiled_letter']:
file_contents = view_letter_notification_as_preview(service_id, notification_id, "pdf")
page_count = pdf_page_count(io.BytesIO(file_contents))
else:
page_count = get_page_count_for_letter(notification['template'])
page_count = get_page_count_for_letter(notification['template'], values=personalisation)
template = get_template(
notification['template'],
@@ -67,7 +69,7 @@ def view_notification(service_id, notification_id):
show_recipient=True,
redact_missing_personalisation=True,
)
template.values = get_all_personalisation_from_notification(notification)
template.values = personalisation
if notification['job']:
job = job_api_client.get_job(service_id, notification['job']['id'])['data']
else:

View File

@@ -142,7 +142,7 @@ def test_notification_page_shows_page_for_letter_notification(
count_of_pages = 3
mock_get_notification(mocker, fake_uuid, template_type='letter', postage='second')
mocker.patch(
mock_page_count = mocker.patch(
'app.main.views.notifications.get_page_count_for_letter',
return_value=count_of_pages
)
@@ -173,6 +173,10 @@ def test_notification_page_shows_page_for_letter_notification(
'.png?page={}'.format(index)
)
assert len(mock_page_count.call_args_list) == 1
assert mock_page_count.call_args_list[0][0][0]['name'] == 'sample template'
assert mock_page_count.call_args_list[0][1]['values'] == {'name': 'Jo'}
@pytest.mark.parametrize('notification_status, expected_message', (
(