mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-23 15:57:23 -04:00
Merge pull request #2442 from alphagov/show-all-pages-notification
Show all letter pages on the notification page
This commit is contained in:
@@ -48,11 +48,13 @@ def view_notification(service_id, notification_id):
|
|||||||
notification = notification_api_client.get_notification(service_id, str(notification_id))
|
notification = notification_api_client.get_notification(service_id, str(notification_id))
|
||||||
notification['template'].update({'reply_to_text': notification['reply_to_text']})
|
notification['template'].update({'reply_to_text': notification['reply_to_text']})
|
||||||
|
|
||||||
|
personalisation = get_all_personalisation_from_notification(notification)
|
||||||
|
|
||||||
if notification['template']['is_precompiled_letter']:
|
if notification['template']['is_precompiled_letter']:
|
||||||
file_contents = view_letter_notification_as_preview(service_id, notification_id, "pdf")
|
file_contents = view_letter_notification_as_preview(service_id, notification_id, "pdf")
|
||||||
page_count = pdf_page_count(io.BytesIO(file_contents))
|
page_count = pdf_page_count(io.BytesIO(file_contents))
|
||||||
else:
|
else:
|
||||||
page_count = get_page_count_for_letter(notification['template'])
|
page_count = get_page_count_for_letter(notification['template'], values=personalisation)
|
||||||
|
|
||||||
template = get_template(
|
template = get_template(
|
||||||
notification['template'],
|
notification['template'],
|
||||||
@@ -67,7 +69,7 @@ def view_notification(service_id, notification_id):
|
|||||||
show_recipient=True,
|
show_recipient=True,
|
||||||
redact_missing_personalisation=True,
|
redact_missing_personalisation=True,
|
||||||
)
|
)
|
||||||
template.values = get_all_personalisation_from_notification(notification)
|
template.values = personalisation
|
||||||
if notification['job']:
|
if notification['job']:
|
||||||
job = job_api_client.get_job(service_id, notification['job']['id'])['data']
|
job = job_api_client.get_job(service_id, notification['job']['id'])['data']
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ def test_notification_page_shows_page_for_letter_notification(
|
|||||||
count_of_pages = 3
|
count_of_pages = 3
|
||||||
|
|
||||||
mock_get_notification(mocker, fake_uuid, template_type='letter', postage='second')
|
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',
|
'app.main.views.notifications.get_page_count_for_letter',
|
||||||
return_value=count_of_pages
|
return_value=count_of_pages
|
||||||
)
|
)
|
||||||
@@ -173,6 +173,10 @@ def test_notification_page_shows_page_for_letter_notification(
|
|||||||
'.png?page={}'.format(index)
|
'.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', (
|
@pytest.mark.parametrize('notification_status, expected_message', (
|
||||||
(
|
(
|
||||||
|
|||||||
Reference in New Issue
Block a user