mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-06-01 12:00:36 -04:00
Don’t error if organisation name is unchanged
If you submit the rename organisation form without making any changes
you will get an error saying that the name is currently in use. This is
true because it’s being used by the current organisation.
However your intention is probably not to actually change anything, so
we can just redirect back to the settings page.
This is the same thing we do when renaming services:
60f5b74904/app/main/views/service_settings.py (L99-L100)
This commit is contained in:
@@ -329,6 +329,10 @@ def edit_organisation_name(org_id):
|
||||
form.name.data = current_organisation.name
|
||||
|
||||
if form.validate_on_submit():
|
||||
|
||||
if form.name.data == current_organisation.name:
|
||||
return redirect(url_for('.organisation_settings', org_id=current_organisation.id))
|
||||
|
||||
unique_name = organisations_client.is_organisation_name_unique(org_id, form.name.data)
|
||||
if not unique_name:
|
||||
form.name.errors.append("This organisation name is already in use")
|
||||
|
||||
@@ -1315,6 +1315,25 @@ def test_confirm_update_organisation_with_incorrect_password(
|
||||
) == 'Error: Invalid password'
|
||||
|
||||
|
||||
def test_confirm_update_organisation_with_existing_name(
|
||||
client_request,
|
||||
platform_admin_user,
|
||||
fake_uuid,
|
||||
mock_get_organisation,
|
||||
):
|
||||
client_request.login(platform_admin_user)
|
||||
client_request.post(
|
||||
'.edit_organisation_name',
|
||||
org_id=fake_uuid,
|
||||
_data={'name': 'Test organisation'},
|
||||
_expected_redirect=url_for(
|
||||
'.organisation_settings',
|
||||
org_id=fake_uuid,
|
||||
_external=True,
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def test_confirm_update_organisation_with_name_already_in_use(
|
||||
client_request,
|
||||
platform_admin_user,
|
||||
|
||||
Reference in New Issue
Block a user