diff --git a/app/main/forms.py b/app/main/forms.py index 35c7dfe43..feaecb3f6 100644 --- a/app/main/forms.py +++ b/app/main/forms.py @@ -1682,7 +1682,7 @@ class ServiceEditInboundNumberForm(StripWhitespaceForm): is_default = GovukCheckboxField("Make this text message sender the default") -class EditServiceNotesForm(StripWhitespaceForm): +class EditNotesForm(StripWhitespaceForm): notes = TextAreaField(validators=[]) diff --git a/app/main/views/organisations.py b/app/main/views/organisations.py index 8ab4eae0f..7a3550110 100644 --- a/app/main/views/organisations.py +++ b/app/main/views/organisations.py @@ -20,6 +20,7 @@ from app.main.forms import ( AddGPOrganisationForm, AddNHSLocalOrganisationForm, ConfirmPasswordForm, + EditNotesForm, GoLiveNotesForm, InviteOrgUserForm, NewOrganisationForm, @@ -531,3 +532,24 @@ def edit_organisation_go_live_notes(org_id): 'views/organisations/organisation/settings/edit-go-live-notes.html', form=form, ) + + +@main.route("/organisations//settings/notes", methods=['GET', 'POST']) +@user_is_platform_admin +def edit_organisation_notes(org_id): + form = EditNotesForm(notes=current_organisation.notes) + + if form.validate_on_submit(): + + if form.notes.data == current_organisation.notes: + return redirect(url_for('.organisation_settings', service_id=org_id)) + + current_organisation.update( + notes=form.notes.data + ) + return redirect(url_for('.organisation_settings', service_id=org_id)) + + return render_template( + 'views/organisations/organisation/settings/edit-organisation-notes.html', + form=form, + ) diff --git a/app/main/views/service_settings.py b/app/main/views/service_settings.py index 54f15f0a8..920866399 100644 --- a/app/main/views/service_settings.py +++ b/app/main/views/service_settings.py @@ -34,7 +34,7 @@ from app.main import main from app.main.forms import ( BrandingOptions, ConfirmPasswordForm, - EditServiceNotesForm, + EditNotesForm, EstimateUsageForm, FreeSMSAllowance, LinkOrganisationsForm, @@ -1193,7 +1193,7 @@ def edit_data_retention(service_id, data_retention_id): @main.route("/services//notes", methods=['GET', 'POST']) @user_is_platform_admin def edit_service_notes(service_id): - form = EditServiceNotesForm(notes=current_service.notes) + form = EditNotesForm(notes=current_service.notes) if form.validate_on_submit(): diff --git a/app/models/organisation.py b/app/models/organisation.py index 4028a0d51..daae6e4f1 100644 --- a/app/models/organisation.py +++ b/app/models/organisation.py @@ -46,6 +46,7 @@ class Organisation(JSONModel): 'domains', 'request_to_go_live_notes', 'count_of_live_services', + 'notes' } @classmethod diff --git a/app/templates/views/organisations/organisation/settings/index.html b/app/templates/views/organisations/organisation/settings/index.html index 6bf5f40ce..a58679938 100644 --- a/app/templates/views/organisations/organisation/settings/index.html +++ b/app/templates/views/organisations/organisation/settings/index.html @@ -71,6 +71,13 @@ ) }} {% endcall %} + + {% call row() %} + {{ text_field('Notes')}} + {{ optional_text_field(current_service.notes, default="No notes yet", wrap=True) }} + {{ edit_field('Change', url_for('.edit_organisation_notes', org_id=current_org.id), suffix='the notes for the organisation') }} + {% endcall %} + {% call row() %} {{ text_field('Default email branding') }} {{ text_field(current_org.email_branding_name) }} diff --git a/tests/__init__.py b/tests/__init__.py index 655c92d27..c67df7a9f 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -218,6 +218,7 @@ def organisation_json( agreement_signed_on_behalf_of_email_address=None, organisation_type='central', request_to_go_live_notes=None, + notes=None, ): if users is None: users = [] @@ -242,6 +243,7 @@ def organisation_json( 'domains': domains or [], 'request_to_go_live_notes': request_to_go_live_notes, 'count_of_live_services': len(services), + 'notes': notes, } diff --git a/tests/app/main/views/organisations/test_organisation.py b/tests/app/main/views/organisations/test_organisation.py index 670dee96d..81639a064 100644 --- a/tests/app/main/views/organisations/test_organisation.py +++ b/tests/app/main/views/organisations/test_organisation.py @@ -691,6 +691,7 @@ def test_organisation_settings_for_platform_admin( 'Crown organisation Yes Change', 'Data sharing and financial agreement Not signed Change', 'Request to go live notes None Change', + 'Notes No notes yet Change the notes for the organisation', 'Default email branding GOV.UK Change', 'Default letter branding No branding Change', 'Known email domains None Change', @@ -1260,3 +1261,18 @@ def test_post_edit_organisation_go_live_notes_updates_go_live_notes( org_id=organisation_one['id'], _external=True ) + + +def test_organisation_settings_links_to_edit_organisation_notes_page( + mocker, + mock_get_organisation, + organisation_one, + platform_admin_client, +): + response = platform_admin_client.get(url_for( + '.organisation_settings', org_id=organisation_one['id'] + )) + page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser') + assert len(page.find_all( + 'a', attrs={'href': '/organisations/{}/settings/notes'.format(organisation_one['id'])} + )) == 1