Allow GPs to click through to the agreement

We want GPs to be able to accept the agreement online. But at the moment
they don’t get automatically assigned to organisations. So we need to
let them enter the agreement accepting journey even if they don’t have
an organisation set up.
This commit is contained in:
Chris Hill-Scott
2019-09-04 15:55:09 +01:00
parent 2fe7887ec6
commit d41effe8ce
4 changed files with 64 additions and 9 deletions

View File

@@ -176,13 +176,8 @@ def estimate_usage(service_id):
@main.route("/services/<service_id>/service-settings/request-to-go-live", methods=['GET']) @main.route("/services/<service_id>/service-settings/request-to-go-live", methods=['GET'])
@user_has_permissions('manage_service') @user_has_permissions('manage_service')
def request_to_go_live(service_id): def request_to_go_live(service_id):
agreement_signed = current_service.organisation.agreement_signed
return render_template( return render_template(
'views/service-settings/request-to-go-live.html', 'views/service-settings/request-to-go-live.html'
show_agreement=agreement_signed is not None,
agreement_signed=agreement_signed,
) )

View File

@@ -591,6 +591,13 @@ class Service(JSONModel):
def get_api_key(self, id): def get_api_key(self, id):
return self._get_by_id(self.api_keys, 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 @property
def request_to_go_live_tags(self): def request_to_go_live_tags(self):
return list(self._get_request_to_go_live_tags()) return list(self._get_request_to_go_live_tags())

View File

@@ -48,9 +48,9 @@
url_for('main.service_sms_senders', service_id=current_service.id), url_for('main.service_sms_senders', service_id=current_service.id),
) }} ) }}
{% endif %} {% endif %}
{% if show_agreement %} {% if current_service.able_to_accept_agreement %}
{{ task_list_item( {{ task_list_item(
agreement_signed, current_service.organisation.agreement_signed,
'Accept our data sharing and financial agreement', 'Accept our data sharing and financial agreement',
url_for('main.service_agreement', service_id=current_service.id), url_for('main.service_agreement', service_id=current_service.id),
) }} ) }}
@@ -60,7 +60,7 @@
<p> <p>
Only team members with a government email address can request to go live. Only team members with a government email address can request to go live.
</p> </p>
{% 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) %}
<p> <p>
You must complete these steps before you can request to go live. You must complete these steps before you can request to go live.
</p> </p>

View File

@@ -1087,6 +1087,59 @@ def test_should_check_for_mou_on_request_to_go_live(
assert normalize_spaces(checklist_items[3].text) == expected_item 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( def test_non_gov_user_is_told_they_cant_go_live(
client_request, client_request,
api_nongov_user_active, api_nongov_user_active,