dont let people get into one-off flow for deleted templates

previously we'd skip the template page entirely if someone didnt have
manage templates/api keys permission. however, if the template is
deleted you'd then go through the flow entering placeholders and stuff
before it would then crash when trying to send.

instead, just bounce the user to the template page. It has the content
and says when the template was deleted.
This commit is contained in:
Leo Hemsted
2021-07-21 16:06:23 +01:00
parent d414e6d345
commit 5da69dd495
4 changed files with 31 additions and 5 deletions

View File

@@ -587,6 +587,32 @@ def test_caseworker_redirected_to_set_sender_for_one_off(
)
@freeze_time('2020-01-01 15:00')
def test_caseworker_sees_template_page_if_template_is_deleted(
client_request,
mock_get_deleted_template,
fake_uuid,
mocker,
active_caseworking_user,
):
mocker.patch('app.user_api_client.get_user', return_value=active_caseworking_user)
template_id = fake_uuid
page = client_request.get(
'.view_template',
service_id=SERVICE_ONE_ID,
template_id=template_id,
_test_page_title=False,
)
content = str(page)
assert url_for("main.send_one_off", service_id=SERVICE_ONE_ID, template_id=fake_uuid) not in content
assert page.select('p.hint')[0].text.strip() == 'This template was deleted today at 3:00pm.'
mock_get_deleted_template.assert_called_with(SERVICE_ONE_ID, template_id, None)
def test_user_with_only_send_and_view_redirected_to_set_sender_for_one_off(
client_request,
mock_get_service_templates,