diff --git a/app/main/__init__.py b/app/main/__init__.py index 97ec7a815..26162357e 100644 --- a/app/main/__init__.py +++ b/app/main/__init__.py @@ -5,7 +5,6 @@ no_cookie = Blueprint('no_cookie', __name__) from app.main.views import ( # noqa isort:skip add_service, - agreement, api_keys, choose_account, code_not_received, diff --git a/app/main/forms.py b/app/main/forms.py index b50b9a75b..f8e1ffb5a 100644 --- a/app/main/forms.py +++ b/app/main/forms.py @@ -1145,25 +1145,6 @@ class OrganisationOrganisationTypeForm(StripWhitespaceForm): organisation_type = OrganisationTypeField('What type of organization is this?') -class OrganisationAgreementSignedForm(StripWhitespaceForm): - agreement_signed = GovukRadiosField( - 'Has this organization signed the agreement?', - choices=[ - ('yes', 'Yes'), - ('no', 'No'), - ('unknown', 'No (but we have some service-specific agreements in place)'), - ], - thing='whether this organization has signed the agreement', - param_extensions={ - 'items': [ - {'hint': {'html': 'Users will be told their organization has already signed the agreement'}}, - {'hint': {'html': 'Users will be prompted to sign the agreement before they can go live'}}, - {'hint': {'html': 'Users will not be prompted to sign the agreement'}} - ] - } - ) - - class AdminOrganisationDomainsForm(StripWhitespaceForm): def populate(self, domains_list): @@ -2094,70 +2075,6 @@ class AdminOrganisationGoLiveNotesForm(StripWhitespaceForm): ) -class AcceptAgreementForm(StripWhitespaceForm): - - @classmethod - def from_organisation(cls, org): - - if org.agreement_signed_on_behalf_of_name and org.agreement_signed_on_behalf_of_email_address: - who = 'someone-else' - elif org.agreement_signed_version: # only set if user has submitted form previously - who = 'me' - else: - who = None - - return cls( - version=org.agreement_signed_version, - who=who, - on_behalf_of_name=org.agreement_signed_on_behalf_of_name, - on_behalf_of_email=org.agreement_signed_on_behalf_of_email_address, - ) - - version = GovukTextInputField( - 'Which version of the agreement do you want to accept?' - ) - - who = RadioField( - 'Who are you accepting the agreement for?', - choices=( - ( - 'me', - 'Yourself', - ), - ( - 'someone-else', - 'Someone else', - ), - ), - ) - - on_behalf_of_name = GovukTextInputField( - 'What’s their name?' - ) - - on_behalf_of_email = email_address( - 'What’s their email address?', - required=False, - gov_user=False, - ) - - def __validate_if_nominating(self, field): - if self.who.data == 'someone-else': - if not field.data: - raise ValidationError('Cannot be empty') - else: - field.data = '' - - validate_on_behalf_of_name = __validate_if_nominating - validate_on_behalf_of_email = __validate_if_nominating - - def validate_version(self, field): - try: - float(field.data) - except (TypeError, ValueError): - raise ValidationError("Must be a number") - - class ChangeSecurityKeyNameForm(StripWhitespaceForm): security_key_name = GovukTextInputField( 'Name of key', diff --git a/app/main/views/agreement.py b/app/main/views/agreement.py deleted file mode 100644 index 13c3a93a5..000000000 --- a/app/main/views/agreement.py +++ /dev/null @@ -1,96 +0,0 @@ -from datetime import datetime - -from flask import abort, redirect, render_template, request, send_file, url_for -from flask_login import current_user - -from app import current_service -from app.main import main -from app.main.forms import AcceptAgreementForm -from app.models.organisation import Organisation -from app.s3_client.s3_mou_client import get_mou -from app.utils.user import user_has_permissions - - -@main.route('/services//agreement') -@user_has_permissions('manage_service') -def service_agreement(service_id): - if not current_service.organisation: - if current_service.organisation_type == Organisation.TYPE_NHS_GP: - return redirect( - url_for('main.add_organisation_from_gp_service', service_id=current_service.id) - ) - if current_service.organisation_type == Organisation.TYPE_NHS_LOCAL: - return redirect( - url_for('main.add_organisation_from_nhs_local_service', service_id=current_service.id) - ) - if current_service.organisation.agreement_signed: - return render_template('views/agreement/service-agreement-signed.html') - return render_template('views/agreement/service-agreement.html') - - -@main.route('/services//agreement.pdf') -@user_has_permissions('manage_service') -def service_download_agreement(service_id): - return send_file(**get_mou()) - - -@main.route('/services//agreement/accept', methods=['GET', 'POST']) -@user_has_permissions('manage_service') -def service_accept_agreement(service_id): - - if not current_service.organisation: - abort(404) - - form = AcceptAgreementForm.from_organisation(current_service.organisation) - - if form.validate_on_submit(): - current_service.organisation.update( - agreement_signed_version=float(form.version.data), - agreement_signed_on_behalf_of_name=form.on_behalf_of_name.data, - agreement_signed_on_behalf_of_email_address=form.on_behalf_of_email.data, - ) - return redirect(url_for('main.service_confirm_agreement', service_id=current_service.id)) - - return render_template( - 'views/agreement/agreement-accept.html', - form=form, - ) - - -@main.route('/services//agreement/confirm', methods=['GET', 'POST']) -@user_has_permissions('manage_service') -def service_confirm_agreement(service_id): - - if ( - not current_service.organisation - or current_service.organisation.agreement_signed_version is None - ): - abort(403) - - if request.method == 'POST': - current_service.organisation.update( - agreement_signed=True, - agreement_signed_at=str(datetime.utcnow()), - agreement_signed_by_id=current_user.id, - ) - return redirect(url_for('main.request_to_go_live', service_id=current_service.id)) - - return render_template('views/agreement/agreement-confirm.html') - - -@main.route('/agreement/', endpoint='public_agreement') -@main.route('/agreement/.pdf', endpoint='public_download_agreement') -def public_agreement(variant): - # originally we returned 404 if variant was not in ['crown', 'not_crown']. Will we be using agreement.pdf? - # for now this is just to keep tests working as expected. - if variant != "agreement": - abort(404) - - if request.endpoint == 'main.public_download_agreement': - return send_file(**get_mou()) - - return render_template( - 'views/agreement/agreement-public.html', - owner=current_user.default_organisation.name, - download_link=url_for('.public_download_agreement', variant=variant), - ) diff --git a/app/main/views/organisations.py b/app/main/views/organisations.py index 3c059fb22..06aa44e8e 100644 --- a/app/main/views/organisations.py +++ b/app/main/views/organisations.py @@ -2,7 +2,7 @@ from collections import OrderedDict from datetime import datetime from functools import partial -from flask import flash, redirect, render_template, request, send_file, url_for +from flask import flash, redirect, render_template, request, url_for from flask_login import current_user from notifications_python_client.errors import HTTPError @@ -22,7 +22,6 @@ from app.main.forms import ( AdminPreviewBrandingForm, AdminSetEmailBrandingForm, InviteOrgUserForm, - OrganisationAgreementSignedForm, OrganisationOrganisationTypeForm, RenameOrganisationForm, SearchByNameForm, @@ -35,7 +34,6 @@ from app.main.views.dashboard import ( from app.main.views.service_settings import get_branding_as_value_and_label from app.models.organisation import AllOrganisations, Organisation from app.models.user import InvitedOrgUser, User -from app.s3_client.s3_mou_client import get_mou from app.utils.csv import Spreadsheet from app.utils.user import user_has_permissions, user_is_platform_admin @@ -277,35 +275,6 @@ def edit_organisation_type(org_id): ) -@main.route("/organisations//settings/edit-agreement", methods=['GET', 'POST']) -@user_is_platform_admin -def edit_organisation_agreement(org_id): - - form = OrganisationAgreementSignedForm( - agreement_signed={ - True: 'yes', - False: 'no', - None: 'unknown', - }.get(current_organisation.agreement_signed) - ) - - if form.validate_on_submit(): - organisations_client.update_organisation( - current_organisation.id, - agreement_signed={ - 'yes': True, - 'no': False, - 'unknown': None, - }.get(form.agreement_signed.data), - ) - return redirect(url_for('.organisation_settings', org_id=org_id)) - - return render_template( - 'views/organisations/organisation/settings/edit-agreement.html', - form=form, - ) - - @main.route("/organisations//settings/set-email-branding", methods=['GET', 'POST']) @user_is_platform_admin def edit_organisation_email_branding(org_id): @@ -464,9 +433,3 @@ def organisation_billing(org_id): return render_template( 'views/organisations/organisation/billing.html' ) - - -@main.route('/organisations//agreement.pdf') -@user_is_platform_admin -def organisation_download_agreement(org_id): - return send_file(**get_mou()) diff --git a/app/models/organisation.py b/app/models/organisation.py index 282c1a851..dc5543d94 100644 --- a/app/models/organisation.py +++ b/app/models/organisation.py @@ -30,12 +30,6 @@ class Organisation(JSONModel, SortByNameMixin): 'active', 'organisation_type', 'email_branding_id', - 'agreement_signed', - 'agreement_signed_at', - 'agreement_signed_by_id', - 'agreement_signed_version', - 'agreement_signed_on_behalf_of_name', - 'agreement_signed_on_behalf_of_email_address', 'domains', 'request_to_go_live_notes', 'count_of_live_services', @@ -68,11 +62,10 @@ class Organisation(JSONModel, SortByNameMixin): ) @classmethod - def create(cls, name, organisation_type, agreement_signed=False): + def create(cls, name, organisation_type): return cls(organisations_client.create_organisation( name=name, organisation_type=organisation_type, - agreement_signed=agreement_signed, )) def __init__(self, _dict): @@ -81,7 +74,6 @@ class Organisation(JSONModel, SortByNameMixin): if self._dict == {}: self.name = None - self.agreement_signed = None self.domains = [] self.organisation_type = None self.request_to_go_live_notes = None @@ -150,12 +142,6 @@ class Organisation(JSONModel, SortByNameMixin): return self.email_branding['name'] return 'GOV.UK' - @cached_property - def agreement_signed_by(self): - if self.agreement_signed_by_id: - from app.models.user import User - return User.from_id(self.agreement_signed_by_id) - def update(self, delete_services_cache=False, **kwargs): response = organisations_client.update_organisation( self.id, diff --git a/app/models/service.py b/app/models/service.py index b16faae37..d3a32a0c6 100644 --- a/app/models/service.py +++ b/app/models/service.py @@ -516,16 +516,6 @@ class Service(JSONModel, SortByNameMixin): 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 in { - Organisation.TYPE_NHS_GP, - Organisation.TYPE_NHS_LOCAL, - } - ) - class Services(SerialisedModelCollection): model = Service diff --git a/app/navigation.py b/app/navigation.py index ef29424f4..ea1712938 100644 --- a/app/navigation.py +++ b/app/navigation.py @@ -191,9 +191,6 @@ class MainNavigation(Navigation): 'request_to_go_live', 'service_add_email_reply_to', 'service_add_sms_sender', - 'service_agreement', - 'service_accept_agreement', - 'service_confirm_agreement', 'service_confirm_delete_email_reply_to', 'service_confirm_delete_sms_sender', 'service_edit_email_reply_to', @@ -262,7 +259,6 @@ class OrgNavigation(Navigation): 'organisation_dashboard', }, 'settings': { - 'edit_organisation_agreement', 'edit_organisation_billing_details', 'edit_organisation_domains', 'edit_organisation_email_branding', diff --git a/app/notify_client/organisations_api_client.py b/app/notify_client/organisations_api_client.py index 85128dc28..21e9e4450 100644 --- a/app/notify_client/organisations_api_client.py +++ b/app/notify_client/organisations_api_client.py @@ -37,13 +37,12 @@ class OrganisationsClient(NotifyAdminAPIClient): raise error @cache.delete('organisations') - def create_organisation(self, name, organisation_type, agreement_signed): + def create_organisation(self, name, organisation_type): return self.post( url="/organisations", data={ "name": name, "organisation_type": organisation_type, - "agreement_signed": agreement_signed, } ) diff --git a/app/s3_client/s3_mou_client.py b/app/s3_client/s3_mou_client.py deleted file mode 100644 index 108d23758..000000000 --- a/app/s3_client/s3_mou_client.py +++ /dev/null @@ -1,22 +0,0 @@ -import botocore -from flask import current_app - -from app.s3_client.s3_logo_client import get_s3_object - - -def get_mou(): - bucket = current_app.config['MOU_BUCKET_NAME'] - filename = 'agreement.pdf' - attachment_filename = 'U.S. Notify data sharing and financial agreement.pdf' - try: - key = get_s3_object(bucket, filename) - return { - 'path_or_file': key.get()['Body'], - 'download_name': attachment_filename, - 'as_attachment': True, - } - except botocore.exceptions.ClientError as exception: - current_app.logger.error("Unable to download s3 file {}/{}".format( - bucket, filename - )) - raise exception diff --git a/app/templates/support-tickets/go-live-request.txt b/app/templates/support-tickets/go-live-request.txt index 4a9482049..ccce379a5 100644 --- a/app/templates/support-tickets/go-live-request.txt +++ b/app/templates/support-tickets/go-live-request.txt @@ -7,9 +7,7 @@ Service: {{ service.name }} --- Organisation type: {{ service.organisation_type_label }} -Agreement signed: {{ organisation.agreement_signed|format_yes_no(none='Can’t tell') }} -{%- if organisation.agreement_signed %}, for {{ current_service.organisation.name }} -{%- elif organisation.name %} (organisation is {{ organisation.name }}) +{%- if organisation.name %} (organisation is {{ organisation.name }}) {%- else %} (domain is {{ user.email_domain }}) {%- endif %}. {%- if organisation.request_to_go_live_notes %} {{ organisation.request_to_go_live_notes }}{% endif %} diff --git a/app/templates/views/agreement/agreement-accept.html b/app/templates/views/agreement/agreement-accept.html deleted file mode 100644 index 3d3ba9171..000000000 --- a/app/templates/views/agreement/agreement-accept.html +++ /dev/null @@ -1,48 +0,0 @@ -{% extends "withnav_template.html" %} -{% from "components/radios.html" import radio, conditional_radio_panel %} -{% from "components/select-input.html" import select_wrapper %} -{% from "components/form.html" import form_wrapper %} -{% from "components/page-footer.html" import page_footer %} -{% from "components/page-header.html" import page_header %} -{% from "components/uk_components/back-link/macro.njk" import govukBackLink %} - -{% block per_page_title %} - Accept our data sharing and financial agreement -{% endblock %} - -{% block backLink %} - {{ govukBackLink({ "href": url_for('main.service_agreement', service_id=current_service.id) }) }} -{% endblock %} - -{% block maincolumn_content %} - -
-
- - {{ page_header('Accept our data sharing and financial agreement') }} - - {% call form_wrapper(class='top-gutter') %} - - {% call select_wrapper(form.who) %} - {% for option in form.who %} - {{ radio(option, data_target='on-behalf-of' if option.data == 'someone-else' else None) }} - {% endfor %} - {% endcall %} - {% call conditional_radio_panel('on-behalf-of') %} - {{ form.on_behalf_of_name(param_extensions={"classes": "govuk-!-width-full"}) }} - {{ form.on_behalf_of_email(param_extensions={"classes": "govuk-!-width-full"}) }} - {% endcall %} - {{ form.version( - param_extensions={ - "hint": {"text": "The version number is on the front page, for example ‘3.6’"}, - "classes": "govuk-!-width-one-third"} - ) }} - - {{ page_footer('Continue') }} - - {% endcall %} - -
-
- -{% endblock %} diff --git a/app/templates/views/agreement/agreement-confirm.html b/app/templates/views/agreement/agreement-confirm.html deleted file mode 100644 index 282b5b6c5..000000000 --- a/app/templates/views/agreement/agreement-confirm.html +++ /dev/null @@ -1,42 +0,0 @@ -{% extends "withnav_template.html" %} -{% from "components/form.html" import form_wrapper %} -{% from "components/page-footer.html" import page_footer %} -{% from "components/page-header.html" import page_header %} -{% from "components/uk_components/back-link/macro.njk" import govukBackLink %} - -{% block per_page_title %} - Confirm that you accept the agreement -{% endblock %} - - -{% block backLink %} - {{ govukBackLink({ "href": url_for('main.service_accept_agreement', service_id=current_service.id) }) }} -{% endblock %} - -{% block maincolumn_content %} - -
-
- - {{ page_header('Confirm that you accept the agreement') }} - - {% call form_wrapper(class='top-gutter') %} - - {% if current_service.organisation.agreement_signed_on_behalf_of_name and current_service.organisation.agreement_signed_on_behalf_of_email_address %} -

- I confirm that I have the legal authority to accept the U.S. Notify data sharing and financial agreement (version {{ current_service.organisation.agreement_signed_version }}) on behalf of {{ current_service.organisation.agreement_signed_on_behalf_of_name }} ({{ current_service.organisation.agreement_signed_on_behalf_of_email_address }}) and that {{ current_service.organisation.name }} will be bound by it. -

- {% else %} -

- I confirm that I have the legal authority to accept the U.S. Notify data sharing and financial agreement (version {{ current_service.organisation.agreement_signed_version }}) and that {{ current_service.organisation.name }} will be bound by it. -

- {% endif %} - - {{ page_footer('Accept this agreement') }} - - {% endcall %} - -
-
- -{% endblock %} diff --git a/app/templates/views/agreement/agreement-public.html b/app/templates/views/agreement/agreement-public.html deleted file mode 100644 index c365c9599..000000000 --- a/app/templates/views/agreement/agreement-public.html +++ /dev/null @@ -1,27 +0,0 @@ -{% extends "withoutnav_template.html" %} -{% from "components/sub-navigation.html" import sub_navigation %} - -{% block per_page_title %} - Download the U.S. Notify data sharing and financial agreement -{% endblock %} - -{% block maincolumn_content %} - -
-
- -

- Download the U.S. Notify data sharing and financial agreement -

- -

- Download the agreement (PDF){% if owner %} for {{ owner }}{% endif %}. -

-

- The agreement contains commercially sensitive information. Do not share it outside your organization. -

- -
-
- -{% endblock %} diff --git a/app/templates/views/agreement/service-agreement-signed.html b/app/templates/views/agreement/service-agreement-signed.html deleted file mode 100644 index 3b3286f72..000000000 --- a/app/templates/views/agreement/service-agreement-signed.html +++ /dev/null @@ -1,31 +0,0 @@ -{% extends "withnav_template.html" %} -{% from "components/page-header.html" import page_header %} -{% from "components/uk_components/back-link/macro.njk" import govukBackLink %} - -{% block service_page_title %} - Your organization has already accepted the agreement -{% endblock %} - -{% block backLink %} - {{ govukBackLink({ "href": url_for('main.request_to_go_live', service_id=current_service.id) }) }} -{% endblock %} - -{% block maincolumn_content %} - -
-
- - {{ page_header('Your organization has already accepted the agreement')}} - -

- {{ current_service.organisation.name }} has already accepted the US - Notify data sharing and financial agreement. -

-

- The agreement is confidential and should not be shared outside your organization. -

- -
-
- -{% endblock %} diff --git a/app/templates/views/agreement/service-agreement.html b/app/templates/views/agreement/service-agreement.html deleted file mode 100644 index 2194c802d..000000000 --- a/app/templates/views/agreement/service-agreement.html +++ /dev/null @@ -1,42 +0,0 @@ -{% extends "withnav_template.html" %} -{% from "components/page-header.html" import page_header %} -{% from "components/uk_components/button/macro.njk" import govukButton %} -{% from "components/uk_components/back-link/macro.njk" import govukBackLink %} - -{% block service_page_title %} - Accept our data sharing and financial agreement -{% endblock %} - -{% block backLink %} - {{ govukBackLink({ "href": url_for('main.request_to_go_live', service_id=current_service.id) }) }} -{% endblock %} - -{% block maincolumn_content %} - -
-
- - {{ page_header('Accept our data sharing and financial agreement')}} - -

- Before you can use U.S. Notify, you need to accept our data sharing and financial agreement. -

-

- This must be done by, or on behalf of, someone with the authority to sign contracts for {{ current_service.organisation.name }}. -

-

- Once accepted, the agreement covers all Notify services from {{ current_service.organisation.name }}. -

-

- The agreement is confidential and should not be shared outside your organization. -

- {{ govukButton({ - "element": "a", - "text": "Continue", - "href": url_for('main.service_accept_agreement', service_id=current_service.id), - }) }} - -
-
- -{% endblock %} diff --git a/app/templates/views/organisations/add-gp-organisation.html b/app/templates/views/organisations/add-gp-organisation.html index 1d15c0257..120ad22ba 100644 --- a/app/templates/views/organisations/add-gp-organisation.html +++ b/app/templates/views/organisations/add-gp-organisation.html @@ -6,16 +6,12 @@ {% from "components/form.html" import form_wrapper %} {% from "components/uk_components/back-link/macro.njk" import govukBackLink %} -{% block per_page_title %} - Accept our data sharing and financial agreement -{% endblock %} {% block backLink %} {{ govukBackLink({ "href": url_for('main.request_to_go_live', service_id=current_service.id) }) }} {% endblock %} {% block maincolumn_content %} - {{ page_header('Accept our data sharing and financial agreement') }} {% call form_wrapper() %} {% call select_wrapper(form.same_as_service_name) %} {% for option in form.same_as_service_name %} diff --git a/app/templates/views/organisations/add-nhs-local-organisation.html b/app/templates/views/organisations/add-nhs-local-organisation.html index d55e2a220..60a5acc64 100644 --- a/app/templates/views/organisations/add-nhs-local-organisation.html +++ b/app/templates/views/organisations/add-nhs-local-organisation.html @@ -5,8 +5,6 @@ {% from "components/form.html" import form_wrapper %} {% from "components/uk_components/back-link/macro.njk" import govukBackLink %} -{% set page_title = "Accept our data sharing and financial agreement" %} - {% block per_page_title %} {{ page_title }} {% endblock %} diff --git a/app/templates/views/organisations/organisation/billing.html b/app/templates/views/organisations/organisation/billing.html index c2b4375bb..b7e852a6a 100644 --- a/app/templates/views/organisations/organisation/billing.html +++ b/app/templates/views/organisations/organisation/billing.html @@ -4,37 +4,3 @@ {% block org_page_title %} Billing {% endblock %} - -{% block maincolumn_content %} - {{ page_header("Billing", size="medium") }} -
-
-

- Data sharing and financial agreement -

- - {% if current_org.agreement_signed_at %} -

- Your organization accepted version {{ current_org.agreement_signed_version }} of the U.S. Notify data sharing - and financial agreement on {{ current_org.agreement_signed_at | format_date_normal }}. -

-

- {{ current_org.agreement_signed_on_behalf_of_name or current_org.agreement_signed_by.name }} signed the agreement - on behalf of {{ current_org.name}}. -

- {% elif current_org.agreement_signed %} -

- {{ current_org.name}} has accepted the U.S. Notify data sharing and financial agreement. -

- {% elif current_org.agreement_signed is false %} -

- {{ current_org.name}} needs to accept the U.S. Notify data sharing and financial agreement. -

- {% elif current_org.agreement_signed is none %} -

- {{ current_org.name}} has not accepted the U.S. Notify data sharing and financial agreement, but we have some service-specific agreements in place. -

- {% endif %} -
-
-{% endblock %} diff --git a/app/templates/views/organisations/organisation/settings/edit-agreement.html b/app/templates/views/organisations/organisation/settings/edit-agreement.html deleted file mode 100644 index a95867538..000000000 --- a/app/templates/views/organisations/organisation/settings/edit-agreement.html +++ /dev/null @@ -1,25 +0,0 @@ -{% extends "org_template.html" %} -{% from "components/page-footer.html" import page_footer %} -{% from "components/page-header.html" import page_header %} -{% from "components/form.html" import form_wrapper %} -{% from "components/uk_components/back-link/macro.njk" import govukBackLink %} - -{% block backLink %} - {{ govukBackLink({ "href": url_for('.organisation_settings', org_id=current_org.id) }) }} -{% endblock %} - -{% block org_page_title %} - Data sharing and financial agreement -{% endblock %} - -{% block maincolumn_content %} - {{ page_header("Data sharing and financial agreement") }} -
-
- {% call form_wrapper() %} - {{ form.agreement_signed }} - {{ page_footer('Save') }} - {% endcall %} -
-
-{% endblock %} diff --git a/app/templates/views/organisations/organisation/settings/index.html b/app/templates/views/organisations/organisation/settings/index.html index fa6942ed8..450c7601a 100644 --- a/app/templates/views/organisations/organisation/settings/index.html +++ b/app/templates/views/organisations/organisation/settings/index.html @@ -34,22 +34,6 @@ ) }} {% endcall %} - {% call row() %} - {{ text_field('Data sharing and financial agreement') }} - {{ text_field( - { - True: 'Signed', - False: 'Not signed', - None: 'Not signed (but we have some service-specific agreements in place)' - }.get(current_org.agreement_signed) - ) }} - {{ edit_field( - 'Change', - url_for('.edit_organisation_agreement', org_id=current_org.id), - suffix='data sharing and financial agreement for the organization' - ) - }} - {% endcall %} {% call row() %} {{ text_field('Request to go live notes') }} {{ optional_text_field(current_org.request_to_go_live_notes, default='None') }} 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 89deead17..bf9ee82ad 100644 --- a/app/templates/views/service-settings/request-to-go-live.html +++ b/app/templates/views/service-settings/request-to-go-live.html @@ -50,19 +50,12 @@ url_for('main.service_sms_senders', service_id=current_service.id), ) }} {% endif %} - {% if current_service.able_to_accept_agreement %} - {{ task_list_item( - current_service.organisation.agreement_signed, - 'Accept our data sharing and financial agreement', - url_for('main.service_agreement', service_id=current_service.id), - ) }} - {% endif %} {% endcall %} {% if not current_user.is_gov_user %}

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

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

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

diff --git a/app/templates/views/trial-mode.html b/app/templates/views/trial-mode.html index 40b685f0f..e1c830dfa 100644 --- a/app/templates/views/trial-mode.html +++ b/app/templates/views/trial-mode.html @@ -36,7 +36,6 @@
  • add examples of the messages you want to send
  • update your settings so you’re ready to send and receive messages
  • -
  • accept our data sharing and financial agreement
  • accept our terms of use
diff --git a/tests/app/main/views/organisations/test_organisations.py b/tests/app/main/views/organisations/test_organisations.py index 303eaaa42..497954970 100644 --- a/tests/app/main/views/organisations/test_organisations.py +++ b/tests/app/main/views/organisations/test_organisations.py @@ -1,12 +1,9 @@ -from unittest import mock - import pytest from flask import url_for from freezegun import freeze_time from notifications_python_client.errors import HTTPError from tests import organisation_json, service_json -from tests.app.main.views.test_agreement import MockS3Object from tests.conftest import ( ORGANISATION_ID, SERVICE_ONE_ID, @@ -144,7 +141,6 @@ def test_create_new_organisation( mock_create_organisation.assert_called_once_with( name='new name', organisation_type='federal', - agreement_signed=False, ) @@ -360,16 +356,11 @@ def test_gps_can_name_their_organisation( service_id=SERVICE_ONE_ID, _data=data, _expected_status=302, - _expected_redirect=url_for( - 'main.service_agreement', - service_id=SERVICE_ONE_ID, - ) ) mock_create_organisation.assert_called_once_with( name=expected_service_name, organisation_type='nhs_gp', - agreement_signed=False, ) mock_update_service_organisation.assert_called_once_with(SERVICE_ONE_ID, ORGANISATION_ID) @@ -430,10 +421,6 @@ def test_nhs_local_assigns_to_selected_organisation( 'organisations': ORGANISATION_ID, }, _expected_status=302, - _expected_redirect=url_for( - 'main.service_agreement', - service_id=SERVICE_ONE_ID, - ) ) mock_update_service_organisation.assert_called_once_with(SERVICE_ONE_ID, ORGANISATION_ID) @@ -918,10 +905,6 @@ def test_organisation_settings_for_platform_admin( 'Label Value Action', 'Name Test organisation Change organization name', 'Sector Federal government Change sector for the organization', - ( - 'Data sharing and financial agreement ' - 'Not signed Change data sharing and financial agreement for the organization' - ), 'Request to go live notes None Change go live notes for the organization', 'Billing details None Change billing details for the organization', 'Notes None Change the notes for the organization', @@ -950,27 +933,6 @@ def test_organisation_settings_for_platform_admin( ), 'federal', ), - ( - '.edit_organisation_agreement', - ( - { - 'value': 'yes', - 'label': 'Yes', - 'hint': 'Users will be told their organization has already signed the agreement' - }, - { - 'value': 'no', - 'label': 'No', - 'hint': 'Users will be prompted to sign the agreement before they can go live' - }, - { - 'value': 'unknown', - 'label': 'No (but we have some service-specific agreements in place)', - 'hint': 'Users will not be prompted to sign the agreement' - }, - ), - 'no', - ), )) @pytest.mark.parametrize('user', ( pytest.param( @@ -1024,21 +986,6 @@ def test_view_organisation_settings( {'organisation_type': 'state'}, {'cached_service_ids': [], 'organisation_type': 'state'}, ), - ( - '.edit_organisation_agreement', - {'agreement_signed': 'yes'}, - {'agreement_signed': True}, - ), - ( - '.edit_organisation_agreement', - {'agreement_signed': 'no'}, - {'agreement_signed': False}, - ), - ( - '.edit_organisation_agreement', - {'agreement_signed': 'unknown'}, - {'agreement_signed': None}, - ), )) @pytest.mark.parametrize('user', ( pytest.param( @@ -1582,137 +1529,3 @@ def test_organisation_billing_page_not_accessible_if_not_platform_admin( org_id=ORGANISATION_ID, _expected_status=403 ) - - -@pytest.mark.parametrize('signed_by_id, signed_by_name, expected_signatory', [ - ('1234', None, 'Test User'), - (None, 'The Org Manager', 'The Org Manager'), - ('1234', 'The Org Manager', 'The Org Manager'), -]) -def test_organisation_billing_page_when_the_agreement_is_signed_by_a_known_person( - organisation_one, - client_request, - api_user_active, - mocker, - platform_admin_user, - signed_by_id, - signed_by_name, - expected_signatory, -): - api_user_active['id'] = '1234' - - organisation_one['agreement_signed'] = True - organisation_one['agreement_signed_version'] = 2.5 - organisation_one['agreement_signed_by_id'] = signed_by_id - organisation_one['agreement_signed_on_behalf_of_name'] = signed_by_name - organisation_one['agreement_signed_at'] = 'Thu, 20 Feb 2020 06:00:00 GMT' - - mocker.patch('app.organisations_client.get_organisation', return_value=organisation_one) - - client_request.login(platform_admin_user) - - mocker.patch('app.user_api_client.get_user', side_effect=[api_user_active]) - - page = client_request.get( - '.organisation_billing', - org_id=ORGANISATION_ID, - ) - - assert page.h1.string == 'Billing' - assert '2.5 of the U.S. Notify data sharing and financial agreement on 20 February 2020' in normalize_spaces( - page.text) - assert f'{expected_signatory} signed' in page.text - # assert page.select_one('main a')['href'] == url_for('.organisation_download_agreement', org_id=ORGANISATION_ID) - - -def test_organisation_billing_page_when_the_agreement_is_signed_by_an_unknown_person( - organisation_one, - client_request, - platform_admin_user, - mocker, -): - organisation_one['agreement_signed'] = True - mocker.patch('app.organisations_client.get_organisation', return_value=organisation_one) - - client_request.login(platform_admin_user) - page = client_request.get( - '.organisation_billing', - org_id=ORGANISATION_ID, - ) - - assert page.h1.string == 'Billing' - assert (f'{organisation_one["name"]} has accepted the U.S. Notify data ' - 'sharing and financial agreement.') in page.text - # assert page.select_one('main a')['href'] == url_for('.organisation_download_agreement', org_id=ORGANISATION_ID) - - -@pytest.mark.parametrize('agreement_signed, expected_content', [ - (False, 'needs to accept'), - (None, 'has not accepted'), -]) -def test_organisation_billing_page_when_the_agreement_is_not_signed( - organisation_one, - client_request, - platform_admin_user, - mocker, - agreement_signed, - expected_content, -): - organisation_one['agreement_signed'] = agreement_signed - mocker.patch('app.organisations_client.get_organisation', return_value=organisation_one) - - client_request.login(platform_admin_user) - page = client_request.get( - '.organisation_billing', - org_id=ORGANISATION_ID, - ) - - assert page.h1.string == 'Billing' - assert f'{organisation_one["name"]} {expected_content}' in page.text - - -@pytest.mark.parametrize('expected_status, expected_file_fetched, expected_file_served', ( - ( - 200, 'agreement.pdf', - 'U.S. Notify data sharing and financial agreement.pdf', - ), -)) -@mock.patch('app.s3_client.s3_mou_client.current_app') -def test_download_organisation_agreement( - mock_flask_current_app, - client_request, - platform_admin_user, - mocker, - expected_status, - expected_file_fetched, - expected_file_served, -): - mock_flask_current_app.config['MOU_BUCKET_NAME'] = 'test-mou' - mocker.patch( - 'app.models.organisation.organisations_client.get_organisation', - return_value=organisation_json( - ) - ) - mock_get_s3_object = mocker.patch( - 'app.s3_client.s3_mou_client.get_s3_object', - return_value=MockS3Object(b'foo') - ) - - client_request.login(platform_admin_user) - response = client_request.get_response( - 'main.organisation_download_agreement', - org_id=ORGANISATION_ID, - _expected_status=expected_status, - ) - - if expected_file_served: - assert response.get_data() == b'foo' - assert response.headers['Content-Type'] == 'application/pdf' - assert response.headers['Content-Disposition'] == ( - f'attachment; filename="{expected_file_served}"' - ) - # mock_get_s3_object.assert_called_once_with('test-mou', expected_file_fetched) - mock_get_s3_object.assert_called_once() - else: - assert not expected_file_fetched - assert mock_get_s3_object.called is False diff --git a/tests/app/main/views/service_settings/test_service_settings.py b/tests/app/main/views/service_settings/test_service_settings.py index 3212da310..4a7d0b736 100644 --- a/tests/app/main/views/service_settings/test_service_settings.py +++ b/tests/app/main/views/service_settings/test_service_settings.py @@ -760,12 +760,10 @@ def test_should_check_for_sending_things_right( mock_get_invites.assert_called_once_with(SERVICE_ONE_ID) -@pytest.mark.parametrize('checklist_completed, agreement_signed, expected_button', ( - (True, True, True), - (True, None, True), - (True, False, False), - (False, True, False), - (False, None, False), +@pytest.mark.parametrize('checklist_completed, expected_button', ( + (True, True), + (True, True), + (False, False), )) def test_should_not_show_go_live_button_if_checklist_not_complete( client_request, @@ -776,7 +774,6 @@ def test_should_not_show_go_live_button_if_checklist_not_complete( mock_get_invites_for_service, single_sms_sender, checklist_completed, - agreement_signed, expected_button, ): mocker.patch( @@ -784,12 +781,6 @@ def test_should_not_show_go_live_button_if_checklist_not_complete( new_callable=PropertyMock, return_value=checklist_completed, ) - mocker.patch( - 'app.models.organisation.Organisation.agreement_signed', - new_callable=PropertyMock, - return_value=agreement_signed, - create=True, - ) for channel in ('email', 'sms'): mocker.patch( @@ -963,68 +954,6 @@ def test_should_check_for_sms_sender_on_go_live( mock_get_sms_senders.assert_called_once_with(SERVICE_ONE_ID) -@pytest.mark.parametrize('agreement_signed, expected_item', ( - pytest.param( - None, - '', - marks=pytest.mark.xfail(raises=IndexError) - ), - ( - True, - 'Accept our data sharing and financial agreement Completed', - ), - ( - False, - 'Accept our data sharing and financial agreement Not completed', - ), -)) -def test_should_check_for_mou_on_request_to_go_live( - client_request, - service_one, - mocker, - agreement_signed, - mock_get_invites_for_service, - mock_get_service_organisation, - expected_item, -): - 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'}: - mocker.patch( - 'app.models.service.Service.volume_{}'.format(channel), - create=True, - new_callable=PropertyMock, - return_value=None, - ) - - mocker.patch( - 'app.organisations_client.get_organisation', - return_value=organisation_json(agreement_signed=agreement_signed) - ) - page = client_request.get( - 'main.request_to_go_live', service_id=SERVICE_ONE_ID - ) - assert page.h1.text == 'Before you request to go live' - - checklist_items = page.select('.task-list .task-list-item') - assert normalize_spaces(checklist_items[3].text) == expected_item - - def test_non_gov_user_is_told_they_cant_go_live( client_request, api_nongov_user_active, @@ -1316,8 +1245,7 @@ def test_should_redirect_after_request_to_go_live( 'http://localhost/services/{service_id}\n' '\n' '---\n' - 'Organisation type: Federal government\n' - 'Agreement signed: Can’t tell (domain is user.gsa.gov).\n' + 'Organisation type: Federal government (domain is user.gsa.gov).\n' '\n' '{formatted_displayed_volumes}' '\n' @@ -1400,8 +1328,7 @@ def test_request_to_go_live_displays_go_live_notes_in_zendesk_ticket( 'http://localhost/services/{service_id}\n' '\n' '---\n' - 'Organisation type: Federal government\n' - 'Agreement signed: No (organisation is Org 1). {go_live_note}\n' + 'Organisation type: Federal government (organisation is Org 1). {go_live_note}\n' '\n' 'Emails in next year: 111,111\n' 'Text messages in next year: 222,222\n' @@ -1472,11 +1399,10 @@ def test_request_to_go_live_displays_mou_signatories( ) assert ( - 'Organisation type: Federal government\n' - 'Agreement signed: Yes, for Org 1.\n' - 'Agreement signed by: test@user.gsa.gov\n' - 'Agreement signed on behalf of: bigdog@example.gsa.gov\n' - '\n' + 'Organisation type: Federal government' + ) in mock_create_ticket.call_args[1]['message'] + + assert ( 'Emails in next year: 111,111\n' ) in mock_create_ticket.call_args[1]['message'] diff --git a/tests/app/main/views/test_agreement.py b/tests/app/main/views/test_agreement.py deleted file mode 100644 index 63cd08069..000000000 --- a/tests/app/main/views/test_agreement.py +++ /dev/null @@ -1,481 +0,0 @@ -from functools import partial -from io import BytesIO -from unittest import mock -from unittest.mock import call - -import pytest -from flask import url_for -from freezegun import freeze_time - -from tests import organisation_json -from tests.conftest import ORGANISATION_ID, SERVICE_ONE_ID, normalize_spaces - - -class MockS3Object(): - - def __init__(self, data=None): - self.data = data or b'' - - def get(self): - return {'Body': BytesIO(self.data)} - - -@pytest.mark.parametrize('agreement_signed, expected_back_link, expected_other_links', [ - ( - True, - partial(url_for, 'main.request_to_go_live', service_id=SERVICE_ONE_ID), - [] - ), - ( - False, - partial(url_for, 'main.request_to_go_live', service_id=SERVICE_ONE_ID), - [ - ( - ['govuk-button'], - partial(url_for, 'main.service_accept_agreement', service_id=SERVICE_ONE_ID), - ), - ] - ), - ( - False, - partial(url_for, 'main.request_to_go_live', service_id=SERVICE_ONE_ID), - [ - ( - ['govuk-button'], - partial(url_for, 'main.service_accept_agreement', service_id=SERVICE_ONE_ID), - ), - ] - ), -]) -def test_show_agreement_page( - client_request, - mocker, - fake_uuid, - mock_get_service_organisation, - mock_has_jobs, - agreement_signed, - expected_back_link, - expected_other_links, -): - org = organisation_json( - agreement_signed=agreement_signed - ) - mocker.patch('app.organisations_client.get_organisation', return_value=org) - - page = client_request.get('main.service_agreement', service_id=SERVICE_ONE_ID) - - back_link = page.select_one('.govuk-back-link') - assert back_link['href'] == expected_back_link() - - links = page.select('main .govuk-grid-column-five-sixths a') - assert len(links) == len(expected_other_links) - for index, link in enumerate(links): - classes, url = expected_other_links[index] - assert link.get('class', []) == classes - assert link['href'] == url() - - -@pytest.mark.parametrize('org_type, expected_endpoint', ( - ('nhs_gp', 'main.add_organisation_from_gp_service'), - ('nhs_local', 'main.add_organisation_from_nhs_local_service'), -)) -@pytest.mark.skip(reason='Update for TTS') -def test_unknown_gps_and_trusts_are_redirected( - client_request, - mocker, - fake_uuid, - mock_has_jobs, - service_one, - org_type, - expected_endpoint, -): - service_one['organisation_id'] = None - service_one['organisation_type'] = org_type - client_request.get( - 'main.service_agreement', - service_id=SERVICE_ONE_ID, - _expected_status=302, - _expected_redirect=url_for( - expected_endpoint, - service_id=SERVICE_ONE_ID, - ), - ) - - -@pytest.mark.parametrize('expected_status, expected_file_fetched, expected_file_served', ( - ( - 200, 'agreement.pdf', - 'U.S. Notify data sharing and financial agreement.pdf', - ), -)) -@mock.patch('app.s3_client.s3_mou_client.current_app') -def test_download_service_agreement( - mock_flask_current_app, - client_request, - mocker, - mock_get_service_organisation, - expected_status, - expected_file_fetched, - expected_file_served, -): - mock_flask_current_app.config['MOU_BUCKET_NAME'] = 'test-mou' - mocker.patch( - 'app.models.organisation.organisations_client.get_organisation', - return_value=organisation_json( - ) - ) - mock_get_s3_object = mocker.patch( - 'app.s3_client.s3_mou_client.get_s3_object', - return_value=MockS3Object(b'foo') - ) - - response = client_request.get_response( - 'main.service_download_agreement', - service_id=SERVICE_ONE_ID, - _expected_status=expected_status, - ) - - if expected_file_served: - assert response.get_data() == b'foo' - assert response.headers['Content-Type'] == 'application/pdf' - assert response.headers['Content-Disposition'] == ( - 'attachment; filename="{}"'.format(expected_file_served) - ) - mock_get_s3_object.assert_called_once() - else: - assert not expected_file_fetched - assert mock_get_s3_object.called is False - - -def test_show_accept_agreement_page( - client_request, - mocker, - mock_get_service_organisation, - mock_get_organisation, -): - page = client_request.get('main.service_accept_agreement', service_id=SERVICE_ONE_ID) - - assert [ - (input['type'], input['name'], input.get('id')) for input in page.select('input') - ] == [ - ('radio', 'who', 'who-0'), - ('radio', 'who', 'who-1'), - ('text', 'on_behalf_of_name', 'on_behalf_of_name'), - ('email', 'on_behalf_of_email', 'on_behalf_of_email'), - ('text', 'version', 'version'), - ('hidden', 'csrf_token', None), - ] - - assert normalize_spaces(page.select_one('label[for=version]').text) == ( - 'Which version of the agreement do you want to accept?' - ) - - assert normalize_spaces(page.select_one('#version-hint').text) == ( - 'The version number is on the front page, for example ‘3.6’' - ) - assert page.select_one('input[name=version]').get('value') is None - - assert normalize_spaces(page.select_one('#who legend').text) == ( - 'Who are you accepting the agreement for?' - ) - assert normalize_spaces(page.select_one('label[for=who-0]').text) == ( - 'Yourself' - ) - assert page.select('input[name=who]')[0]['value'] == 'me' - assert 'checked' not in page.select('input[name=who]')[0] - assert 'data-target' not in page.select('.multiple-choice')[0] - assert normalize_spaces(page.select_one('label[for=who-1]').text) == ( - 'Someone else' - ) - assert page.select('input[name=who]')[1]['value'] == 'someone-else' - assert 'checked' not in page.select('input[name=who]')[1] - assert page.select('.multiple-choice')[1]['data-target'] == 'on-behalf-of' - assert [ - field['name'] - for field in page.select('#on-behalf-of.conditional-radios-panel input') - ] == [ - 'on_behalf_of_name', 'on_behalf_of_email' - ] - - assert normalize_spaces(page.select_one('label[for=on_behalf_of_name]').text) == ( - 'What’s their name?' - ) - assert page.select_one('input[name=on_behalf_of_name]').get('value') is None - - assert normalize_spaces(page.select_one('label[for=on_behalf_of_email]').text) == ( - 'What’s their email address?' - ) - assert page.select_one('input[name=on_behalf_of_email]').get('value') is None - - -def test_accept_agreement_page_populates( - client_request, - mocker, - mock_get_service_organisation, -): - mocker.patch( - 'app.models.organisation.organisations_client.get_organisation', - return_value=organisation_json( - agreement_signed_version='1.2', - agreement_signed_on_behalf_of_name='Firstname Lastname', - agreement_signed_on_behalf_of_email_address='test@example.com', - ) - ) - - page = client_request.get('main.service_accept_agreement', service_id=SERVICE_ONE_ID) - - assert [ - (field['name'], field['value']) for field in page.select('input[type=text], input[type=email]') - ] == [ - ('on_behalf_of_name', 'Firstname Lastname'), - ('on_behalf_of_email', 'test@example.com'), - ('version', '1.2'), - ] - assert 'checked' not in page.select('input[name=who]')[0] - assert page.select('input[name=who]')[1]['checked'] == '' - - -@pytest.mark.parametrize('data, expected_errors', ( - ( - { - 'version': '', - 'on_behalf_of_name': '', - 'on_behalf_of_email': '', - }, - [ - 'Select an option', - 'Error: Must be a number', - ], - ), - ( - { - 'version': 'one point two', - 'who': 'me', - 'on_behalf_of_name': '', - 'on_behalf_of_email': '', - }, - [ - 'Error: Must be a number', - ], - ), - ( - { - 'version': '1.2', - 'who': 'someone-else', - 'on_behalf_of_name': '', - 'on_behalf_of_email': '', - }, - [ - 'Error: Cannot be empty', - 'Error: Cannot be empty', - ], - ), - ( - { - 'version': '1.2', - 'who': 'someone-else', - 'on_behalf_of_name': 'Firstname Lastname', - 'on_behalf_of_email': '', - }, - [ - 'Error: Cannot be empty', - ], - ), - ( - { - 'version': '1.2', - 'who': 'someone-else', - 'on_behalf_of_name': '', - 'on_behalf_of_email': 'test@example.com', - }, - [ - 'Error: Cannot be empty', - ], - ), - -)) -def test_accept_agreement_page_validates( - mocker, - client_request, - mock_get_service_organisation, - data, - expected_errors, -): - page = client_request.post( - 'main.service_accept_agreement', - service_id=SERVICE_ONE_ID, - _data=data, - _expected_status=200, - ) - assert [ - error.text.strip() for error in page.select('.govuk-error-message, .error-message') - ] == expected_errors - - -@pytest.mark.parametrize('data, expected_persisted', ( - ( - { - 'version': '1.2', - 'who': 'someone-else', - 'on_behalf_of_name': 'Firstname Lastname', - 'on_behalf_of_email': 'test@example.com', - }, - call( - ORGANISATION_ID, - agreement_signed_version=1.2, - agreement_signed_on_behalf_of_name='Firstname Lastname', - agreement_signed_on_behalf_of_email_address='test@example.com', - cached_service_ids=None, - ) - ), - ( - { - 'version': '1.2', - 'who': 'me', - 'on_behalf_of_name': 'Firstname Lastname', - 'on_behalf_of_email': 'test@example.com', - }, - call( - ORGANISATION_ID, - agreement_signed_version=1.2, - agreement_signed_on_behalf_of_name='', - agreement_signed_on_behalf_of_email_address='', - cached_service_ids=None, - ) - ), - ( - { - 'version': '1.2', - 'who': 'me', - 'on_behalf_of_name': '', - 'on_behalf_of_email': '', - }, - call( - ORGANISATION_ID, - agreement_signed_version=1.2, - agreement_signed_on_behalf_of_name='', - agreement_signed_on_behalf_of_email_address='', - cached_service_ids=None, - ) - ), -)) -def test_accept_agreement_page_persists( - mocker, - client_request, - mock_get_service_organisation, - mock_update_organisation, - data, - expected_persisted, -): - client_request.post( - 'main.service_accept_agreement', - service_id=SERVICE_ONE_ID, - _data=data, - _expected_status=302, - _expected_redirect=url_for( - 'main.service_confirm_agreement', - service_id=SERVICE_ONE_ID, - ), - ) - assert mock_update_organisation.call_args_list == [expected_persisted] - - -@pytest.mark.parametrize('name, email, expected_paragraph', ( - (None, None, ( - 'I confirm that I have the legal authority to accept the ' - 'U.S. Notify data sharing and financial agreement (version ' - '1.2) and that Test Organisation will be bound by it.' - )), - ('Firstname Lastname', 'test@example.com', ( - 'I confirm that I have the legal authority to accept the ' - 'U.S. Notify data sharing and financial agreement (version ' - '1.2) on behalf of Firstname Lastname (test@example.com) and ' - 'that Test Organisation will be bound by it.' - )), -)) -def test_show_confirm_agreement_page( - client_request, - mocker, - mock_get_service_organisation, - name, - email, - expected_paragraph, -): - mocker.patch( - 'app.models.organisation.organisations_client.get_organisation', - return_value=organisation_json( - agreement_signed_version='1.2', - agreement_signed_on_behalf_of_name=name, - agreement_signed_on_behalf_of_email_address=email, - ) - ) - page = client_request.get('main.service_confirm_agreement', service_id=SERVICE_ONE_ID) - assert normalize_spaces(page.select_one('main p').text) == expected_paragraph - - -@pytest.mark.parametrize('http_method', ('get', 'post')) -def test_confirm_agreement_page_403s_if_previous_step_not_taken( - client_request, - mock_get_organisation, - http_method, -): - getattr(client_request, http_method)( - 'main.service_confirm_agreement', - service_id=SERVICE_ONE_ID, - _expected_status=403, - ) - - -@freeze_time("2012-01-01 01:01") -def test_confirm_agreement_page_persists( - client_request, - mocker, - mock_get_service_organisation, - mock_update_organisation, - fake_uuid, -): - mocker.patch( - 'app.models.organisation.organisations_client.get_organisation', - return_value=organisation_json(agreement_signed_version='1.2') - ) - client_request.post( - 'main.service_confirm_agreement', - service_id=SERVICE_ONE_ID, - _expected_redirect=url_for( - 'main.request_to_go_live', - service_id=SERVICE_ONE_ID, - ), - ) - mock_update_organisation.assert_called_once_with( - '1234', - agreement_signed=True, - agreement_signed_at='2012-01-01 01:01:00', - agreement_signed_by_id=fake_uuid, - cached_service_ids=None, - ) - - -@pytest.mark.parametrize('endpoint', ( - 'main.public_agreement', - 'main.public_download_agreement', -)) -@pytest.mark.parametrize('variant, expected_status', ( - ('foo', 404), -)) -def test_show_public_agreement_page( - client_request, - mocker, - endpoint, - variant, - expected_status, -): - mocker.patch( - 'app.s3_client.s3_mou_client.get_s3_object', - return_value=MockS3Object() - ) - client_request.logout() - client_request.get_response( - endpoint, - variant=variant, - _expected_status=expected_status, - ) diff --git a/tests/app/models/test_user.py b/tests/app/models/test_user.py index e778b2f19..47aab5aca 100644 --- a/tests/app/models/test_user.py +++ b/tests/app/models/test_user.py @@ -8,7 +8,6 @@ def test_anonymous_user(notify_admin): assert AnonymousUser().is_authenticated is False assert AnonymousUser().logged_in_elsewhere() is False assert AnonymousUser().default_organisation.name is None - assert AnonymousUser().default_organisation.agreement_signed is None assert AnonymousUser().default_organisation.domains == [] assert AnonymousUser().default_organisation.organisation_type is None assert AnonymousUser().default_organisation.request_to_go_live_notes is None diff --git a/tests/app/test_navigation.py b/tests/app/test_navigation.py index e5e85794f..86347d6d4 100644 --- a/tests/app/test_navigation.py +++ b/tests/app/test_navigation.py @@ -69,7 +69,6 @@ EXCLUDED_ENDPOINTS = tuple(map(Navigation.get_endpoint_with_blueprint, { 'download_organisation_usage_report', 'edit_and_format_messages', 'edit_data_retention', - 'edit_organisation_agreement', 'edit_organisation_billing_details', 'edit_organisation_domains', 'edit_organisation_email_branding', @@ -144,7 +143,6 @@ EXCLUDED_ENDPOINTS = tuple(map(Navigation.get_endpoint_with_blueprint, { 'old_using_notify', 'organisation_billing', 'organisation_dashboard', - 'organisation_download_agreement', 'organisation_preview_email_branding', 'organisation_settings', 'organisation_trial_mode_services', @@ -156,8 +154,6 @@ EXCLUDED_ENDPOINTS = tuple(map(Navigation.get_endpoint_with_blueprint, { 'platform_admin_splash_page', 'pricing', 'privacy', - 'public_agreement', - 'public_download_agreement', 'received_text_messages_callback', 'redact_template', 'register', @@ -182,18 +178,14 @@ EXCLUDED_ENDPOINTS = tuple(map(Navigation.get_endpoint_with_blueprint, { 'send_one_off', 'send_one_off_step', 'send_one_off_to_myself', - 'service_accept_agreement', 'service_add_email_reply_to', 'service_add_sms_sender', - 'service_agreement', - 'service_confirm_agreement', 'service_confirm_delete_email_reply_to', 'service_confirm_delete_sms_sender', 'service_dashboard', 'service_dashboard_updates', 'service_delete_email_reply_to', 'service_delete_sms_sender', - 'service_download_agreement', 'service_edit_email_reply_to', 'service_edit_sms_sender', 'service_email_reply_to',