mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-09 03:53:13 -04:00
Show all pages of a letter on the preview page
We’ve had a support ticket saying: > Hi, where a letter goes over to two sides, is there a way in the > 'Preview' screen (or anywhere else) that I can see page two? I can > see page one OK, but can't work out how to see what's generated on the > second page. Whether you’re about to send 1000s of letters – or just want to preview how one will look – it’s probably useful to be able to see more than just the first page.
This commit is contained in:
@@ -547,6 +547,7 @@ def _check_messages(service_id, template_id, upload_id, preview_row, letters_as_
|
|||||||
) if not letters_as_pdf else None,
|
) if not letters_as_pdf else None,
|
||||||
email_reply_to=email_reply_to,
|
email_reply_to=email_reply_to,
|
||||||
sms_sender=sms_sender,
|
sms_sender=sms_sender,
|
||||||
|
page_count=get_page_count_for_letter(db_template),
|
||||||
)
|
)
|
||||||
recipients = RecipientCSV(
|
recipients = RecipientCSV(
|
||||||
contents,
|
contents,
|
||||||
@@ -661,7 +662,7 @@ def check_messages_preview(service_id, template_id, upload_id, filetype, row_ind
|
|||||||
template = _check_messages(
|
template = _check_messages(
|
||||||
service_id, template_id, upload_id, row_index, letters_as_pdf=True
|
service_id, template_id, upload_id, row_index, letters_as_pdf=True
|
||||||
)['template']
|
)['template']
|
||||||
return TemplatePreview.from_utils_template(template, filetype)
|
return TemplatePreview.from_utils_template(template, filetype, page=request.args.get('page', 1))
|
||||||
|
|
||||||
|
|
||||||
@main.route("/services/<service_id>/start-job/<upload_id>", methods=['POST'])
|
@main.route("/services/<service_id>/start-job/<upload_id>", methods=['POST'])
|
||||||
|
|||||||
@@ -711,6 +711,10 @@ def test_upload_valid_csv_only_sets_meta_if_filename_known(
|
|||||||
addressline1, addressline2, postcode
|
addressline1, addressline2, postcode
|
||||||
House , 1 Street , SW1A 1AA
|
House , 1 Street , SW1A 1AA
|
||||||
""")
|
""")
|
||||||
|
mocker.patch(
|
||||||
|
'app.main.views.send.get_page_count_for_letter',
|
||||||
|
return_value=5,
|
||||||
|
)
|
||||||
mocker.patch(
|
mocker.patch(
|
||||||
'app.main.views.send.TemplatePreview.from_utils_template',
|
'app.main.views.send.TemplatePreview.from_utils_template',
|
||||||
return_value='foo'
|
return_value='foo'
|
||||||
@@ -2304,7 +2308,14 @@ def test_check_messages_back_link(
|
|||||||
extra_args,
|
extra_args,
|
||||||
expected_url
|
expected_url
|
||||||
):
|
):
|
||||||
|
|
||||||
template_mock(mocker)
|
template_mock(mocker)
|
||||||
|
|
||||||
|
mocker.patch(
|
||||||
|
'app.main.views.send.get_page_count_for_letter',
|
||||||
|
return_value=5,
|
||||||
|
)
|
||||||
|
|
||||||
with logged_in_client.session_transaction() as session:
|
with logged_in_client.session_transaction() as session:
|
||||||
session['file_uploads'] = {
|
session['file_uploads'] = {
|
||||||
fake_uuid: {
|
fake_uuid: {
|
||||||
@@ -2493,6 +2504,10 @@ def test_check_messages_shows_trial_mode_error_for_letters(
|
|||||||
['address_line_1,address_line_2,postcode,'] +
|
['address_line_1,address_line_2,postcode,'] +
|
||||||
['First Last, 123 Street, SW1 1AA'] * number_of_rows
|
['First Last, 123 Street, SW1 1AA'] * number_of_rows
|
||||||
))
|
))
|
||||||
|
mocker.patch(
|
||||||
|
'app.main.views.send.get_page_count_for_letter',
|
||||||
|
return_value=3,
|
||||||
|
)
|
||||||
|
|
||||||
with client_request.session_transaction() as session:
|
with client_request.session_transaction() as session:
|
||||||
session['file_uploads'] = {
|
session['file_uploads'] = {
|
||||||
@@ -2520,6 +2535,8 @@ def test_check_messages_shows_trial_mode_error_for_letters(
|
|||||||
else:
|
else:
|
||||||
assert not error
|
assert not error
|
||||||
|
|
||||||
|
assert len(page.select('.letter img')) == 3
|
||||||
|
|
||||||
if number_of_rows > 1:
|
if number_of_rows > 1:
|
||||||
assert page.select_one('.table-field-index a').text == '3'
|
assert page.select_one('.table-field-index a').text == '3'
|
||||||
|
|
||||||
@@ -2541,6 +2558,11 @@ def test_check_messages_shows_data_errors_before_trial_mode_errors_for_letters(
|
|||||||
[' , ,11SW1 1AA']
|
[' , ,11SW1 1AA']
|
||||||
))
|
))
|
||||||
|
|
||||||
|
mocker.patch(
|
||||||
|
'app.main.views.send.get_page_count_for_letter',
|
||||||
|
return_value=5,
|
||||||
|
)
|
||||||
|
|
||||||
with client_request.session_transaction() as session:
|
with client_request.session_transaction() as session:
|
||||||
session['file_uploads'] = {
|
session['file_uploads'] = {
|
||||||
fake_uuid: {
|
fake_uuid: {
|
||||||
@@ -2582,6 +2604,11 @@ def test_check_messages_column_error_doesnt_show_optional_columns(
|
|||||||
['First Lastname,1 Example Road,SW1 1AA']
|
['First Lastname,1 Example Road,SW1 1AA']
|
||||||
))
|
))
|
||||||
|
|
||||||
|
mocker.patch(
|
||||||
|
'app.main.views.send.get_page_count_for_letter',
|
||||||
|
return_value=5,
|
||||||
|
)
|
||||||
|
|
||||||
with client_request.session_transaction() as session:
|
with client_request.session_transaction() as session:
|
||||||
session['file_uploads'] = {
|
session['file_uploads'] = {
|
||||||
fake_uuid: {
|
fake_uuid: {
|
||||||
@@ -2623,6 +2650,11 @@ def test_generate_test_letter_doesnt_block_in_trial_mode(
|
|||||||
First Last, 123 Street, SW1 1AA
|
First Last, 123 Street, SW1 1AA
|
||||||
""")
|
""")
|
||||||
|
|
||||||
|
mocker.patch(
|
||||||
|
'app.main.views.send.get_page_count_for_letter',
|
||||||
|
return_value=5,
|
||||||
|
)
|
||||||
|
|
||||||
with client_request.session_transaction() as session:
|
with client_request.session_transaction() as session:
|
||||||
session['file_uploads'] = {
|
session['file_uploads'] = {
|
||||||
fake_uuid: {
|
fake_uuid: {
|
||||||
@@ -2641,6 +2673,7 @@ def test_generate_test_letter_doesnt_block_in_trial_mode(
|
|||||||
|
|
||||||
assert not page.select('.banner-dangerous')
|
assert not page.select('.banner-dangerous')
|
||||||
|
|
||||||
|
assert len(page.select('.letter img')) == 5
|
||||||
assert page.select_one('a.button').text == 'Download as a printable PDF'
|
assert page.select_one('a.button').text == 'Download as a printable PDF'
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user