mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-03 03:10:44 -04:00
Don’t send caseworkers back to template page
Caseworkers skip the template page in their message sending journey. Instead they go straight from picking a template to the first step of sending. So the ‘Back’ link should send them straight back to the picking a template page, skipping the individual template page (which they don’t have permission to view).
This commit is contained in:
@@ -766,14 +766,20 @@ def get_back_link(service_id, template_id, step_index):
|
||||
else:
|
||||
return None
|
||||
elif step_index == 0:
|
||||
return url_for(
|
||||
'.view_template',
|
||||
service_id=service_id,
|
||||
template_id=template_id,
|
||||
)
|
||||
if current_user.has_permissions('view_activity'):
|
||||
return url_for(
|
||||
'.view_template',
|
||||
service_id=service_id,
|
||||
template_id=template_id,
|
||||
)
|
||||
else:
|
||||
return url_for(
|
||||
'.choose_template',
|
||||
service_id=service_id,
|
||||
)
|
||||
else:
|
||||
return url_for(
|
||||
request.endpoint,
|
||||
'main.send_one_off_step',
|
||||
service_id=service_id,
|
||||
template_id=template_id,
|
||||
step_index=step_index - 1,
|
||||
@@ -803,8 +809,7 @@ def _check_notification(service_id, template_id, exception=None):
|
||||
sms_sender=sms_sender
|
||||
)
|
||||
|
||||
# go back to start of process
|
||||
back_link = get_back_link(service_id, template_id, 0)
|
||||
back_link = get_back_link(service_id, template_id, len(fields_to_fill_in(template)))
|
||||
|
||||
if (
|
||||
not session.get('recipient') or
|
||||
|
||||
@@ -1327,7 +1327,7 @@ def test_send_test_email_message_without_placeholders_redirects_to_check_page(
|
||||
|
||||
@pytest.mark.parametrize('user, expected_back_link_endpoint, extra_args', (
|
||||
(active_user_with_permissions, 'main.view_template', {'template_id': unchanging_fake_uuid}),
|
||||
(active_caseworking_user, 'main.view_template', {'template_id': unchanging_fake_uuid}),
|
||||
(active_caseworking_user, 'main.choose_template', {}),
|
||||
))
|
||||
def test_send_test_sms_message_with_placeholders_shows_first_field(
|
||||
logged_in_client,
|
||||
@@ -1513,7 +1513,7 @@ def test_send_test_indicates_optional_address_columns(
|
||||
'Optional'
|
||||
)
|
||||
assert page.select('.page-footer-back-link')[0]['href'] == url_for(
|
||||
'main.send_test_step',
|
||||
'main.send_one_off_step',
|
||||
service_id=service_one['id'],
|
||||
template_id=fake_uuid,
|
||||
step_index=2,
|
||||
@@ -2542,9 +2542,10 @@ def test_check_notification_redirects_if_session_not_populated(
|
||||
))
|
||||
|
||||
assert resp.location == url_for(
|
||||
'main.view_template',
|
||||
'main.send_one_off_step',
|
||||
service_id=service_one['id'],
|
||||
template_id=fake_uuid,
|
||||
step_index=1,
|
||||
_external=True
|
||||
)
|
||||
|
||||
@@ -2600,9 +2601,10 @@ def test_check_notification_shows_preview(
|
||||
assert (
|
||||
page.findAll('a', {'class': 'page-footer-back-link'})[0]['href']
|
||||
) == url_for(
|
||||
'main.view_template',
|
||||
'main.send_one_off_step',
|
||||
service_id=service_one['id'],
|
||||
template_id=fake_uuid,
|
||||
step_index=0,
|
||||
)
|
||||
|
||||
# assert tour not visible
|
||||
|
||||
Reference in New Issue
Block a user