From 08bc893ddf5c56b46faec958517ea25249805853 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Tue, 2 Jul 2019 10:09:08 +0100 Subject: [PATCH] Redirect to new organisation after creation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The thing you want to do after creating an org is probably set some domains or default branding, so let’s take you to the page where you can do that. --- app/main/views/organisations.py | 6 ++++-- .../app/main/views/organisations/test_organisation.py | 10 ++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/app/main/views/organisations.py b/app/main/views/organisations.py index 5a705969e..fb7514261 100644 --- a/app/main/views/organisations.py +++ b/app/main/views/organisations.py @@ -54,8 +54,10 @@ def add_organisation(): form = NewOrganisationForm() if form.validate_on_submit(): - Organisation.create_from_form(form) - return redirect(url_for('.organisations')) + return redirect(url_for( + '.organisation_settings', + org_id=Organisation.create_from_form(form).id, + )) return render_template( 'views/organisations/add-organisation.html', diff --git a/tests/app/main/views/organisations/test_organisation.py b/tests/app/main/views/organisations/test_organisation.py index 79f7a06bb..6ca33206e 100644 --- a/tests/app/main/views/organisations/test_organisation.py +++ b/tests/app/main/views/organisations/test_organisation.py @@ -103,7 +103,8 @@ def test_create_new_organisation( mocker, ): mock_create_organisation = mocker.patch( - 'app.organisations_client.create_organisation' + 'app.organisations_client.create_organisation', + return_value=organisation_json(ORGANISATION_ID), ) client_request.login(platform_admin_user) @@ -113,7 +114,12 @@ def test_create_new_organisation( 'name': 'new name', 'organisation_type': 'local', 'crown_status': 'non-crown', - } + }, + _expected_redirect=url_for( + 'main.organisation_settings', + org_id=ORGANISATION_ID, + _external=True, + ), ) mock_create_organisation.assert_called_once_with(