From a5b36457f2d46de5881f18bd3c6b7ee63d8ee161 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Tue, 27 Aug 2019 15:45:59 +0100 Subject: [PATCH] =?UTF-8?q?Add=20=E2=80=98GP=E2=80=99=20as=20an=20org=20ty?= =?UTF-8?q?pe?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Although their allowances are the same as what we call `nhs_local` it makes more sense to store them separately because: - we already present them as two separate choices to the user - we may want to handle them differently in the future, eg in terms of what branding choices are available to them --- app/models.py | 4 +- migrations/versions/0305_add_gp_org_type.py | 42 +++++++++++++++++++++ tests/app/organisation/test_rest.py | 5 ++- 3 files changed, 48 insertions(+), 3 deletions(-) create mode 100644 migrations/versions/0305_add_gp_org_type.py diff --git a/app/models.py b/app/models.py index adb90b43b..d4e2da9f0 100644 --- a/app/models.py +++ b/app/models.py @@ -326,11 +326,11 @@ class Domain(db.Model): ORGANISATION_TYPES = [ - "central", "local", "nhs_central", "nhs_local", "emergency_service", "school_or_college", "other", + "central", "local", "nhs_central", "nhs_local", "gp", "emergency_service", "school_or_college", "other", ] CROWN_ORGANISATION_TYPES = ["nhs_central"] -NON_CROWN_ORGANISATION_TYPES = ["local", "nhs_local", "emergency_service", "school_or_college"] +NON_CROWN_ORGANISATION_TYPES = ["local", "nhs_local", "gp", "emergency_service", "school_or_college"] class OrganisationTypes(db.Model): diff --git a/migrations/versions/0305_add_gp_org_type.py b/migrations/versions/0305_add_gp_org_type.py new file mode 100644 index 000000000..3ac230683 --- /dev/null +++ b/migrations/versions/0305_add_gp_org_type.py @@ -0,0 +1,42 @@ +import os + +""" + +Revision ID: 0305_add_gp_org_type +Revises: 0304_remove_org_to_service +Create Date: 2019-07-24 16:18:27.467361 + +""" +from alembic import op + + +revision = '0305_add_gp_org_type' +down_revision = '0304_remove_org_to_service' +GP_ORG_TYPE_NAME = 'gp' + + +def upgrade(): + op.execute(""" + INSERT INTO + organisation_types + (name, is_crown, annual_free_sms_fragment_limit) + VALUES + ('{}', false, 25000) + """.format(GP_ORG_TYPE_NAME)) + + +def downgrade(): + op.execute(""" + UPDATE + organisation + SET + organisation_type = 'nhs_local' + WHERE + organisation_type = '{}' + """.format(GP_ORG_TYPE_NAME)) + op.execute(""" + DELETE FROM + organisation_types + WHERE + name = '{}' + """.format(GP_ORG_TYPE_NAME)) diff --git a/tests/app/organisation/test_rest.py b/tests/app/organisation/test_rest.py index b6d0f0341..5dbd6cd67 100644 --- a/tests/app/organisation/test_rest.py +++ b/tests/app/organisation/test_rest.py @@ -204,7 +204,10 @@ def test_post_create_organisation_existing_name_raises_400(admin_request, sample 'name': 'Service name', 'crown': False, 'organisation_type': 'foo', - }, 'organisation_type foo is not one of [central, local, nhs_central, nhs_local, emergency_service, school_or_college, other]'), # noqa + }, ( + 'organisation_type foo is not one of ' + '[central, local, nhs_central, nhs_local, gp, emergency_service, school_or_college, other]' + )), )) def test_post_create_organisation_with_missing_data_gives_validation_error( admin_request,