diff --git a/app/main/views/service_settings.py b/app/main/views/service_settings.py index fa150b198..2a4733ff3 100644 --- a/app/main/views/service_settings.py +++ b/app/main/views/service_settings.py @@ -176,13 +176,8 @@ def estimate_usage(service_id): @main.route("/services//service-settings/request-to-go-live", methods=['GET']) @user_has_permissions('manage_service') def request_to_go_live(service_id): - - agreement_signed = current_service.organisation.agreement_signed - return render_template( - 'views/service-settings/request-to-go-live.html', - show_agreement=agreement_signed is not None, - agreement_signed=agreement_signed, + 'views/service-settings/request-to-go-live.html' ) diff --git a/app/models/service.py b/app/models/service.py index 5d4ce1df8..5151c0bc3 100644 --- a/app/models/service.py +++ b/app/models/service.py @@ -591,6 +591,13 @@ class Service(JSONModel): def get_api_key(self, id): return self._get_by_id(self.api_keys, id) + @property + def able_to_accept_agreement(self): + return ( + self.organisation.agreement_signed is not None + or self.organisation_type == 'nhs_gp' + ) + @property def request_to_go_live_tags(self): return list(self._get_request_to_go_live_tags()) diff --git a/app/templates/views/service-settings/request-to-go-live.html b/app/templates/views/service-settings/request-to-go-live.html index fdef9fb1b..15ea7e6a1 100644 --- a/app/templates/views/service-settings/request-to-go-live.html +++ b/app/templates/views/service-settings/request-to-go-live.html @@ -48,9 +48,9 @@ url_for('main.service_sms_senders', service_id=current_service.id), ) }} {% endif %} - {% if show_agreement %} + {% if current_service.able_to_accept_agreement %} {{ task_list_item( - agreement_signed, + current_service.organisation.agreement_signed, 'Accept our data sharing and financial agreement', url_for('main.service_agreement', service_id=current_service.id), ) }} @@ -60,7 +60,7 @@

Only team members with a government email address can request to go live.

- {% elif (not current_service.go_live_checklist_completed) or (show_agreement and not agreement_signed) %} + {% elif (not current_service.go_live_checklist_completed) or (current_service.able_to_accept_agreement and not current_service.organisation.agreement_signed) %}

You must complete these steps before you can request to go live.

diff --git a/tests/app/main/views/test_service_settings.py b/tests/app/main/views/test_service_settings.py index 3d024e4a2..1aa3f9ff3 100644 --- a/tests/app/main/views/test_service_settings.py +++ b/tests/app/main/views/test_service_settings.py @@ -1087,6 +1087,59 @@ def test_should_check_for_mou_on_request_to_go_live( assert normalize_spaces(checklist_items[3].text) == expected_item +@pytest.mark.parametrize('organisation_type', ( + 'nhs_gp', + pytest.param( + 'central', + marks=pytest.mark.xfail(raises=IndexError) + ), +)) +def test_gp_without_organisation_is_shown_agreement_step( + client_request, + service_one, + mocker, + organisation_type, +): + mocker.patch( + 'app.models.service.Service.has_team_members', + return_value=False, + ) + mocker.patch( + 'app.models.service.Service.all_templates', + new_callable=PropertyMock, + return_value=[], + ) + mocker.patch( + 'app.main.views.service_settings.service_api_client.get_sms_senders', + return_value=[], + ) + mocker.patch( + 'app.main.views.service_settings.service_api_client.get_reply_to_email_addresses', + return_value=[], + ) + for channel in {'email', 'sms', 'letter'}: + mocker.patch( + 'app.models.service.Service.volume_{}'.format(channel), + create=True, + new_callable=PropertyMock, + return_value=None, + ) + + mocker.patch('app.organisations_client.get_service_organisation', return_value=None) + service_one['organisation_id'] = None + service_one['organisation_type'] = organisation_type + + page = client_request.get( + 'main.request_to_go_live', service_id=SERVICE_ONE_ID + ) + assert page.h1.text == 'Before you request to go live' + assert normalize_spaces( + page.select('.task-list .task-list-item')[3].text + ) == ( + 'Accept our data sharing and financial agreement Not completed' + ) + + def test_non_gov_user_is_told_they_cant_go_live( client_request, api_nongov_user_active,