mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-23 15:57:23 -04:00
Merge pull request #2551 from alphagov/one_off_bug
Back button on one-off message preview takes user to their flow
This commit is contained in:
@@ -390,7 +390,11 @@ def send_test_step(service_id, template_id, step_index):
|
|||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
current_placeholder = placeholders[step_index]
|
if request.endpoint == 'main.send_test_step':
|
||||||
|
current_placeholder = placeholders[step_index - 1]
|
||||||
|
else:
|
||||||
|
current_placeholder = placeholders[step_index]
|
||||||
|
|
||||||
except IndexError:
|
except IndexError:
|
||||||
if all_placeholders_in_session(placeholders):
|
if all_placeholders_in_session(placeholders):
|
||||||
return get_notification_check_endpoint(service_id, template)
|
return get_notification_check_endpoint(service_id, template)
|
||||||
@@ -450,7 +454,7 @@ def send_test_step(service_id, template_id, step_index):
|
|||||||
):
|
):
|
||||||
skip_link = (
|
skip_link = (
|
||||||
'Use my {}'.format(first_column_headings[template.template_type][0]),
|
'Use my {}'.format(first_column_headings[template.template_type][0]),
|
||||||
url_for('.send_test', service_id=service_id, template_id=template.id),
|
url_for('.send_test_step', service_id=service_id, template_id=template.id, step_index=1),
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
skip_link = None
|
skip_link = None
|
||||||
@@ -798,6 +802,14 @@ def get_send_test_page_title(template_type, help_argument, entering_recipient, n
|
|||||||
return 'Personalise this message'
|
return 'Personalise this message'
|
||||||
|
|
||||||
|
|
||||||
|
def is_current_user_the_recipient():
|
||||||
|
if 'recipient' not in session:
|
||||||
|
return False
|
||||||
|
if hasattr(current_user, 'phone_number'):
|
||||||
|
return session['recipient'] in {current_user.email_address, current_user.phone_number}
|
||||||
|
return session['recipient'] == current_user.email_address
|
||||||
|
|
||||||
|
|
||||||
def get_back_link(service_id, template, step_index):
|
def get_back_link(service_id, template, step_index):
|
||||||
if get_help_argument():
|
if get_help_argument():
|
||||||
# if we're on the check page, redirect back to the beginning. anywhere else, don't return the back link
|
# if we're on the check page, redirect back to the beginning. anywhere else, don't return the back link
|
||||||
@@ -822,6 +834,13 @@ def get_back_link(service_id, template, step_index):
|
|||||||
service_id=service_id,
|
service_id=service_id,
|
||||||
template_id=template.id,
|
template_id=template.id,
|
||||||
)
|
)
|
||||||
|
elif is_current_user_the_recipient() and step_index > 1:
|
||||||
|
return url_for(
|
||||||
|
'main.send_test_step',
|
||||||
|
service_id=service_id,
|
||||||
|
template_id=template.id,
|
||||||
|
step_index=step_index - 1,
|
||||||
|
)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
return url_for(
|
return url_for(
|
||||||
|
|||||||
@@ -1117,13 +1117,13 @@ def test_send_one_off_or_test_has_correct_page_titles(
|
|||||||
active_user_with_permissions,
|
active_user_with_permissions,
|
||||||
mock_get_service_template,
|
mock_get_service_template,
|
||||||
'Use my phone number',
|
'Use my phone number',
|
||||||
partial(url_for, 'main.send_test')
|
partial(url_for, 'main.send_test_step')
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
active_user_with_permissions,
|
active_user_with_permissions,
|
||||||
mock_get_service_email_template,
|
mock_get_service_email_template,
|
||||||
'Use my email address',
|
'Use my email address',
|
||||||
partial(url_for, 'main.send_test')
|
partial(url_for, 'main.send_test_step')
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
active_user_with_permissions,
|
active_user_with_permissions,
|
||||||
@@ -1166,6 +1166,7 @@ def test_send_one_off_has_skip_link(
|
|||||||
assert skip_links[0]['href'] == expected_link_url(
|
assert skip_links[0]['href'] == expected_link_url(
|
||||||
service_id=service_one['id'],
|
service_id=service_one['id'],
|
||||||
template_id=fake_uuid,
|
template_id=fake_uuid,
|
||||||
|
step_index=1
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
assert not skip_links
|
assert not skip_links
|
||||||
@@ -1679,7 +1680,7 @@ def test_send_test_indicates_optional_address_columns(
|
|||||||
page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser')
|
page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser')
|
||||||
|
|
||||||
assert normalize_spaces(page.select('label')[0].text) == (
|
assert normalize_spaces(page.select('label')[0].text) == (
|
||||||
'address line 4 '
|
'address line 3 '
|
||||||
'Optional'
|
'Optional'
|
||||||
)
|
)
|
||||||
assert page.select('.page-footer-back-link')[0]['href'] == url_for(
|
assert page.select('.page-footer-back-link')[0]['href'] == url_for(
|
||||||
|
|||||||
Reference in New Issue
Block a user