Show all letter pages on the notification page

Sometimes a long placeholder can push stuff onto a new page, so we need
to take the personalisation into account when counting pages.
This commit is contained in:
Chris Hill-Scott
2018-11-02 14:18:58 +00:00
parent 549e48de49
commit 39c51dd994
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: