Check for templates before going live

We need users to have created some templates before they go live, so we
can see what kind of messages they intend to send.

We can do this automatically based on the work done in
https://github.com/alphagov/notifications-admin/pull/1892
This commit is contained in:
Chris Hill-Scott
2018-02-27 12:07:50 +00:00
parent ca3fdfd907
commit 7be08e2f74
3 changed files with 30 additions and 4 deletions

View File

@@ -169,6 +169,9 @@ def request_to_go_live(service_id):
service_id, 'manage_settings'
) > 1
),
has_templates=(
service_api_client.count_service_templates(service_id) > 0
),
)

View File

@@ -22,6 +22,10 @@
has_team_members,
'Another person in your team has the Manage service permission',
) }}
{{ tick_cross_done_not_done(
has_templates,
'Youve added some templates',
) }}
</ul>
<p>
You also need to:
@@ -35,7 +39,7 @@
<a href="{{ url_for('main.service_settings', service_id=current_service.id) }}">settings</a> page
</li>
<li>
add the templates you want to start with, making sure they follow the GOV.UK Service Manual standards for
make sure your messages follow the GOV.UK Service Manual standards for
<a href="https://www.gov.uk/service-manual/design/sending-emails-and-text-messages">writing text messages and emails</a>
</li>
</ul>

View File

@@ -455,30 +455,46 @@ def test_should_raise_duplicate_name_handled(
assert mock_verify_password.called
@pytest.mark.parametrize('count_of_users_with_manage_service, expected_checklist_item', [
@pytest.mark.parametrize('count_of_users_with_manage_service, expected_user_checklist_item', [
(1, 'Not done: Another person in your team has the Manage service permission'),
(2, 'Done: Another person in your team has the Manage service permission'),
])
@pytest.mark.parametrize('count_of_templates, expected_templates_checklist_item', [
(0, 'Not done: Youve added some templates'),
(1, 'Done: Youve added some templates'),
(2, 'Done: Youve added some templates'),
])
def test_should_show_request_to_go_live_checklist(
client_request,
mocker,
count_of_users_with_manage_service,
expected_checklist_item,
expected_user_checklist_item,
count_of_templates,
expected_templates_checklist_item,
):
mock_count_users = mocker.patch(
'app.main.views.service_settings.user_api_client.get_count_of_users_with_permission',
return_value=count_of_users_with_manage_service
)
mock_count_templates = mocker.patch(
'app.main.views.service_settings.service_api_client.count_service_templates',
return_value=count_of_templates
)
page = client_request.get(
'main.request_to_go_live', service_id=SERVICE_ONE_ID
)
assert page.h1.text == 'Request to go live'
assert normalize_spaces(page.select('main ul li')[0].text) == expected_checklist_item
assert normalize_spaces(page.select('main ul li')[0].text) == expected_user_checklist_item
assert normalize_spaces(page.select('main ul li')[1].text) == expected_templates_checklist_item
assert page.select_one('main .button')['href'] == url_for(
'main.submit_request_to_go_live',
service_id=SERVICE_ONE_ID,
)
mock_count_users.assert_called_once_with(SERVICE_ONE_ID, 'manage_settings')
mock_count_templates.assert_called_once_with(SERVICE_ONE_ID)
def test_should_show_request_to_go_live(
@@ -577,6 +593,7 @@ def test_route_permissions(
single_sms_sender,
route,
mock_get_service_settings_page_common,
mock_get_service_templates,
):
validate_route_permission(
mocker,
@@ -606,6 +623,7 @@ def test_route_invalid_permissions(
api_user_active,
service_one,
route,
mock_get_service_templates,
):
validate_route_permission(
mocker,
@@ -637,6 +655,7 @@ def test_route_for_platform_admin(
single_sms_sender,
route,
mock_get_service_settings_page_common,
mock_get_service_templates,
):
validate_route_permission(mocker,
app_,