From 8ea748f6e456822529d6132d28808586cf138e8f Mon Sep 17 00:00:00 2001 From: Pea Tyczynska Date: Thu, 4 Feb 2021 17:58:35 +0000 Subject: [PATCH] Update organisation notes --- app/main/views/organisations.py | 4 ++-- .../organisation/settings/index.html | 2 +- .../views/organisations/test_organisations.py | 24 +++++++++++++++++++ 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/app/main/views/organisations.py b/app/main/views/organisations.py index 7a3550110..2bb395cdc 100644 --- a/app/main/views/organisations.py +++ b/app/main/views/organisations.py @@ -542,12 +542,12 @@ def edit_organisation_notes(org_id): if form.validate_on_submit(): if form.notes.data == current_organisation.notes: - return redirect(url_for('.organisation_settings', service_id=org_id)) + return redirect(url_for('.organisation_settings', org_id=org_id)) current_organisation.update( notes=form.notes.data ) - return redirect(url_for('.organisation_settings', service_id=org_id)) + return redirect(url_for('.organisation_settings', org_id=org_id)) return render_template( 'views/organisations/organisation/settings/edit-organisation-notes.html', diff --git a/app/templates/views/organisations/organisation/settings/index.html b/app/templates/views/organisations/organisation/settings/index.html index 0bd7e4542..2a3810d12 100644 --- a/app/templates/views/organisations/organisation/settings/index.html +++ b/app/templates/views/organisations/organisation/settings/index.html @@ -80,7 +80,7 @@ {% call row() %} {{ text_field('Notes')}} - {{ optional_text_field(current_service.notes, default="No notes yet", wrap=True) }} + {{ optional_text_field(current_org.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 %} diff --git a/tests/app/main/views/organisations/test_organisations.py b/tests/app/main/views/organisations/test_organisations.py index a8a3ba6d2..e44d90775 100644 --- a/tests/app/main/views/organisations/test_organisations.py +++ b/tests/app/main/views/organisations/test_organisations.py @@ -1289,3 +1289,27 @@ def test_view_edit_organisation_notes( assert page.select_one('h1').text == "Edit organisation notes" assert page.find('label', class_="form-label").text.strip() == "Notes" assert page.find('textarea').attrs["name"] == "notes" + + +def test_update_organisation_notes( + platform_admin_client, + organisation_one, + mock_get_organisation, + mock_update_organisation, +): + response = platform_admin_client.post( + url_for( + 'main.edit_organisation_notes', + org_id=organisation_one['id'], + ), + data={'notes': "Very fluffy"} + ) + assert response.status_code == 302 + settings_url = url_for( + 'main.organisation_settings', org_id=organisation_one['id'], _external=True) + assert settings_url == response.location + mock_update_organisation.assert_called_with( + organisation_one['id'], + cached_service_ids=None, + notes="Very fluffy" + )