Update organisation notes

This commit is contained in:
Pea Tyczynska
2021-02-04 17:58:35 +00:00
parent e090d97997
commit 8ea748f6e4
3 changed files with 27 additions and 3 deletions

View File

@@ -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',

View File

@@ -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 %}

View File

@@ -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"
)