From c7ab9f7f1af4f604088aeca7e02f360ccda3a43f Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Tue, 27 Mar 2018 11:13:09 +0100 Subject: [PATCH] Link to the page to download the agreement MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We prefer people downloading the agreement if they can. If we don’t know which agreement they should be using (ie we don’t know their crown status) then we fall back to having them contact us. --- app/templates/views/terms-of-use.html | 21 ++++---------- app/utils.py | 40 ++++++++++++++++++++++++++- tests/app/main/views/test_index.py | 29 +++++++++++++++++-- 3 files changed, 71 insertions(+), 19 deletions(-) diff --git a/app/templates/views/terms-of-use.html b/app/templates/views/terms-of-use.html index f90530c14..0902beeb2 100644 --- a/app/templates/views/terms-of-use.html +++ b/app/templates/views/terms-of-use.html @@ -20,21 +20,12 @@ Terms of use These terms apply to your service’s use of GOV.UK Notify. You must be the service manager to accept them.

- {% if agreement_info.agreement_signed %} -

Your organisation ({{ agreement_info.owner }}) has already accepted the GOV.UK Notify data sharing and financial agreement.

- {% else %} -

- Your organisation - {% if agreement_info.owner %} - ({{ agreement_info.owner }}) - must also accept our data sharing and financial agreement. - Contact us to get a copy. - {% else %} - must also accept our data sharing and financial agreement. - Contact us to get a copy. - {% endif %} -

- {% endif %} +

+ {{ agreement_info.as_terms_of_use_paragraph( + download_link=url_for('.agreement'), + contact_link=url_for('.feedback', ticket_type='ask-question-give-feedback', body='agreement-with-owner') + )}} +

When using Notify

You must:

diff --git a/app/utils.py b/app/utils.py index 5466416ef..8f5719529 100644 --- a/app/utils.py +++ b/app/utils.py @@ -15,7 +15,15 @@ import dateutil import pyexcel import pytz import yaml -from flask import abort, current_app, redirect, request, session, url_for +from flask import ( + Markup, + abort, + current_app, + redirect, + request, + session, + url_for, +) from flask_login import current_user from notifications_utils.recipients import RecipientCSV from notifications_utils.template import ( @@ -464,6 +472,36 @@ class AgreementInfo: else: return 'Can’t tell' + def as_terms_of_use_paragraph(self, **kwargs): + return Markup(self._as_terms_of_use_paragraph(**kwargs)) + + def _as_terms_of_use_paragraph(self, download_link, contact_link): + + if self.agreement_signed: + return ( + 'Your organisation ({}) has already accepted the ' + 'GOV.UK Notify data sharing and financial ' + 'agreement.'.format(self.owner) + ) + + if self.crown_status is not None: + return (( + '{} Download a copy.' + ).format(self._acceptance_required, download_link)) + + return (( + '{} Contact us to get a copy.' + ).format(self._acceptance_required, contact_link)) + + @property + def _acceptance_required(self): + return ( + 'Your organisation {} must also accept our data sharing ' + 'and financial agreement.'.format( + '({})'.format(self.owner) if self.owner else '', + ) + ) + @property def crown_status_or_404(self): if self.crown_status is None: diff --git a/tests/app/main/views/test_index.py b/tests/app/main/views/test_index.py index 4ee404698..c4d64a524 100644 --- a/tests/app/main/views/test_index.py +++ b/tests/app/main/views/test_index.py @@ -1,3 +1,5 @@ +from functools import partial + import pytest from bs4 import BeautifulSoup from flask import url_for @@ -102,13 +104,19 @@ def test_terms_is_generic_if_user_is_not_logged_in( ) -@pytest.mark.parametrize('email_address, expected_terms_paragraph, expected_pricing_paragraph', [ +@pytest.mark.parametrize(( + 'email_address,' + 'expected_terms_paragraph,' + 'expected_terms_link,' + 'expected_pricing_paragraph' +), [ ( 'test@cabinet-office.gov.uk', ( 'Your organisation (Cabinet Office) has already accepted ' 'the GOV.UK Notify data sharing and financial agreement.' ), + None, ( 'Contact us to get a copy of the agreement ' '(Cabinet Office has already accepted it).' @@ -118,8 +126,12 @@ def test_terms_is_generic_if_user_is_not_logged_in( 'test@aylesburytowncouncil.gov.uk', ( 'Your organisation (Aylesbury Town Council) must also ' - 'accept our data sharing and financial agreement. Contact ' - 'us to get a copy.' + 'accept our data sharing and financial agreement. Download ' + 'a copy.' + ), + partial( + url_for, + 'main.agreement', ), ( 'Contact us to get a copy of the agreement ' @@ -132,6 +144,12 @@ def test_terms_is_generic_if_user_is_not_logged_in( 'Your organisation must also accept our data sharing and ' 'financial agreement. Contact us to get a copy.' ), + partial( + url_for, + 'main.feedback', + ticket_type='ask-question-give-feedback', + body='agreement-with-owner', + ), ( 'Contact us to get a copy of the agreement or find out if ' 'we already have one in place with your organisation.' @@ -144,6 +162,7 @@ def test_terms_tells_logged_in_users_what_we_know_about_their_agreement( client_request, email_address, expected_terms_paragraph, + expected_terms_link, expected_pricing_paragraph, ): user = active_user_with_permissions(fake_uuid) @@ -152,4 +171,8 @@ def test_terms_tells_logged_in_users_what_we_know_about_their_agreement( terms_page = client_request.get('main.terms') pricing_page = client_request.get('main.pricing') assert normalize_spaces(terms_page.select('main p')[1].text) == expected_terms_paragraph + if expected_terms_link: + assert terms_page.select_one('main p a')['href'] == expected_terms_link() + else: + assert not terms_page.select_one('main p').select('a') assert normalize_spaces(pricing_page.select('main p')[-1].text) == expected_pricing_paragraph