diff --git a/app/broadcast_message/utils.py b/app/broadcast_message/utils.py index 0aa500eca..429e34607 100644 --- a/app/broadcast_message/utils.py +++ b/app/broadcast_message/utils.py @@ -89,7 +89,7 @@ def _create_p1_zendesk_alert(broadcast_message): ticket_type=NotifySupportTicket.TYPE_INCIDENT, technical_ticket=True, org_id=current_app.config['BROADCAST_ORGANISATION_ID'], - org_type='central', + org_type='federal', service_id=str(broadcast_message.service_id), p1=True ) diff --git a/app/commands.py b/app/commands.py index ad944178d..0515a755f 100644 --- a/app/commands.py +++ b/app/commands.py @@ -462,7 +462,7 @@ def replay_daily_sorted_count_files(file_extension): help="Pipe delimited file containing organisation name, sector, crown, argeement_signed, domains") def populate_organisations_from_file(file_name): # [0] organisation name:: name of the organisation insert if organisation is missing. - # [1] sector:: Central | Local | NHS only + # [1] sector:: Federal | State only # [2] crown:: TRUE | FALSE only # [3] argeement_signed:: TRUE | FALSE # [4] domains:: comma separated list of domains related to the organisation diff --git a/app/dao/annual_billing_dao.py b/app/dao/annual_billing_dao.py index 2a593bfb1..56cd7901d 100644 --- a/app/dao/annual_billing_dao.py +++ b/app/dao/annual_billing_dao.py @@ -55,46 +55,21 @@ def dao_get_all_free_sms_fragment_limit(service_id): def set_default_free_allowance_for_service(service, year_start=None): default_free_sms_fragment_limits = { - 'central': { + 'federal': { 2020: 250_000, 2021: 150_000, 2022: 40_000, }, - 'local': { - 2020: 25_000, - 2021: 25_000, - 2022: 20_000, - }, - 'nhs_central': { + 'state': { 2020: 250_000, 2021: 150_000, 2022: 40_000, }, - 'nhs_local': { - 2020: 25_000, - 2021: 25_000, - 2022: 20_000, - }, - 'nhs_gp': { - 2020: 25_000, - 2021: 10_000, - 2022: 10_000, - }, - 'emergency_service': { - 2020: 25_000, - 2021: 25_000, - 2022: 20_000, - }, - 'school_or_college': { - 2020: 25_000, - 2021: 10_000, - 2022: 10_000, - }, 'other': { - 2020: 25_000, - 2021: 10_000, - 2022: 10_000, - }, + 2020: 250_000, + 2021: 150_000, + 2022: 40_000, + } } if not year_start: year_start = get_current_financial_year_start_year() diff --git a/app/dao/services_dao.py b/app/dao/services_dao.py index 1f951dcb7..f8c60272f 100644 --- a/app/dao/services_dao.py +++ b/app/dao/services_dao.py @@ -16,14 +16,11 @@ from app.dao.service_sms_sender_dao import insert_service_sms_sender from app.dao.service_user_dao import dao_get_service_user from app.dao.template_folder_dao import dao_get_valid_template_folders_by_id from app.models import ( - CROWN_ORGANISATION_TYPES, EMAIL_TYPE, INTERNATIONAL_LETTERS, INTERNATIONAL_SMS_TYPE, KEY_TYPE_TEST, LETTER_TYPE, - NHS_ORGANISATION_TYPES, - NON_CROWN_ORGANISATION_TYPES, NOTIFICATION_PERMANENT_FAILURE, SMS_TYPE, UPLOAD_LETTERS, @@ -324,16 +321,8 @@ def dao_create_service( if organisation.letter_branding: service.letter_branding = organisation.letter_branding - elif service.organisation_type in NHS_ORGANISATION_TYPES or email_address_is_nhs(user.email_address): - service.email_branding = dao_get_email_branding_by_name('NHS') - service.letter_branding = dao_get_letter_branding_by_name('NHS') - if organisation: service.crown = organisation.crown - elif service.organisation_type in CROWN_ORGANISATION_TYPES: - service.crown = True - elif service.organisation_type in NON_CROWN_ORGANISATION_TYPES: - service.crown = False service.count_as_live = not user.platform_admin db.session.add(service) diff --git a/app/models.py b/app/models.py index a69188531..2447ea58e 100644 --- a/app/models.py +++ b/app/models.py @@ -352,12 +352,12 @@ class Domain(db.Model): ORGANISATION_TYPES = [ - "central", "local", "nhs_central", "nhs_local", "nhs_gp", "emergency_service", "school_or_college", "other", + "federal", "state", "other" ] -CROWN_ORGANISATION_TYPES = ["nhs_central"] -NON_CROWN_ORGANISATION_TYPES = ["local", "nhs_local", "nhs_gp", "emergency_service", "school_or_college"] -NHS_ORGANISATION_TYPES = ["nhs_central", "nhs_local", "nhs_gp"] +# CROWN_ORGANISATION_TYPES = ["nhs_central"] +# NON_CROWN_ORGANISATION_TYPES = ["local", "nhs_local", "nhs_gp", "emergency_service", "school_or_college"] +# NHS_ORGANISATION_TYPES = ["nhs_central", "nhs_local", "nhs_gp"] class OrganisationTypes(db.Model): diff --git a/app/organisation/rest.py b/app/organisation/rest.py index f7184fbe3..a44cb8b9c 100644 --- a/app/organisation/rest.py +++ b/app/organisation/rest.py @@ -22,7 +22,7 @@ from app.dao.services_dao import dao_fetch_service_by_id from app.dao.templates_dao import dao_get_template_by_id from app.dao.users_dao import get_user_by_id from app.errors import InvalidRequest, register_errors -from app.models import KEY_TYPE_NORMAL, NHS_ORGANISATION_TYPES, Organisation +from app.models import KEY_TYPE_NORMAL, Organisation from app.notifications.process_notifications import ( persist_notification, send_notification_to_queue, @@ -93,9 +93,6 @@ def create_organisation(): validate(data, post_create_organisation_schema) - if data["organisation_type"] in NHS_ORGANISATION_TYPES: - data["email_branding_id"] = current_app.config['NHS_EMAIL_BRANDING_ID'] - organisation = Organisation(**data) dao_create_organisation(organisation) return jsonify(organisation.serialize()), 201 @@ -108,9 +105,6 @@ def update_organisation(organisation_id): organisation = dao_get_organisation_by_id(organisation_id) - if data.get('organisation_type') in NHS_ORGANISATION_TYPES and not organisation.email_branding_id: - data["email_branding_id"] = current_app.config['NHS_EMAIL_BRANDING_ID'] - result = dao_update_organisation(organisation_id, **data) if data.get('agreement_signed') is True: diff --git a/migrations/versions/0376_add_org_names.py b/migrations/versions/0376_add_org_names.py new file mode 100644 index 000000000..76d539e88 --- /dev/null +++ b/migrations/versions/0376_add_org_names.py @@ -0,0 +1,29 @@ +""" + +Revision ID: 0376_add_org_names +Revises: 0375_fix_service_name +Create Date: 2022-09-23 20:04:00.766980 + +""" +from alembic import op +import sqlalchemy as sa +from sqlalchemy.dialects import postgresql + +revision = '0376_add_org_names' +down_revision = '0375_fix_service_name' + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.get_bind() + + op.execute("INSERT INTO organisation_types VALUES ('state','f','250000'),('federal','f','250000');") + + + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + pass + # ### end Alembic commands ### diff --git a/tests/app/billing/test_rest.py b/tests/app/billing/test_rest.py index f02b41b88..b4213a8f7 100644 --- a/tests/app/billing/test_rest.py +++ b/tests/app/billing/test_rest.py @@ -108,7 +108,7 @@ def test_get_free_sms_fragment_limit_current_year_creates_new_row_if_annual_bill ) assert json_response['financial_year_start'] == 2021 - assert json_response['free_sms_fragment_limit'] == 10000 # based on other organisation type + assert json_response['free_sms_fragment_limit'] == 150000 # based on other organisation type def test_update_free_sms_fragment_limit_data(client, sample_service): diff --git a/tests/app/dao/test_annual_billing_dao.py b/tests/app/dao/test_annual_billing_dao.py index de91048de..56e191462 100644 --- a/tests/app/dao/test_annual_billing_dao.py +++ b/tests/app/dao/test_annual_billing_dao.py @@ -47,31 +47,17 @@ def test_dao_update_annual_billing_for_future_years(notify_db_session, sample_se @pytest.mark.parametrize('org_type, year, expected_default', - [('central', 2021, 150000), - ('local', 2021, 25000), - ('nhs_central', 2021, 150000), - ('nhs_local', 2021, 25000), - ('nhs_gp', 2021, 10000), - ('emergency_service', 2021, 25000), - ('school_or_college', 2021, 10000), - ('other', 2021, 10000), - (None, 2021, 10000), - ('central', 2020, 250000), - ('local', 2020, 25000), - ('nhs_central', 2020, 250000), - ('nhs_local', 2020, 25000), - ('nhs_gp', 2020, 25000), - ('emergency_service', 2020, 25000), - ('school_or_college', 2020, 25000), - ('other', 2020, 25000), - (None, 2020, 25000), - ('central', 2019, 250000), - ('school_or_college', 2022, 10000), - ('central', 2022, 40000), - ('local', 2022, 20000), - ('nhs_local', 2022, 20000), - ('emergency_service', 2022, 20000), - ('central', 2023, 40000), + [('federal', 2021, 150000), + ('state', 2021, 150000), + (None, 2021, 150000), + ('federal', 2020, 250000), + ('state', 2020, 250000), + ('other', 2020, 250000), + (None, 2020, 250000), + ('federal', 2019, 250000), + ('federal', 2022, 40000), + ('state', 2022, 40000), + ('federal', 2023, 40000), ]) def test_set_default_free_allowance_for_service(notify_db_session, org_type, year, expected_default): @@ -93,7 +79,7 @@ def test_set_default_free_allowance_for_service_using_correct_year(sample_servic mock_dao.assert_called_once_with( sample_service.id, - 25000, + 250000, 2020 ) @@ -105,9 +91,9 @@ def test_set_default_free_allowance_for_service_updates_existing_year(sample_ser assert not sample_service.organisation_type assert len(annual_billing) == 1 assert annual_billing[0].service_id == sample_service.id - assert annual_billing[0].free_sms_fragment_limit == 10000 + assert annual_billing[0].free_sms_fragment_limit == 150000 - sample_service.organisation_type = 'central' + sample_service.organisation_type = 'federal' set_default_free_allowance_for_service(service=sample_service, year_start=None) annual_billing = AnnualBilling.query.all() diff --git a/tests/app/dao/test_services_dao.py b/tests/app/dao/test_services_dao.py index ef6589277..626bdc3b4 100644 --- a/tests/app/dao/test_services_dao.py +++ b/tests/app/dao/test_services_dao.py @@ -162,6 +162,7 @@ def test_create_service_with_organisation(notify_db_session): # the NHS branding set up ('SHN', False), )) +@pytest.mark.skip(reason='Update for TTS') def test_create_nhs_service_get_default_branding_based_on_email_address( notify_db_session, branding_name_to_create, diff --git a/tests/app/db.py b/tests/app/db.py index 65b8a06b6..1a95df800 100644 --- a/tests/app/db.py +++ b/tests/app/db.py @@ -122,7 +122,7 @@ def create_service( email_from=None, prefix_sms=True, message_limit=1000, - organisation_type='central', + organisation_type='federal', check_if_service_exists=False, go_live_user=None, go_live_at=None, diff --git a/tests/app/organisation/test_rest.py b/tests/app/organisation/test_rest.py index 13f2fa305..cc5d68a23 100644 --- a/tests/app/organisation/test_rest.py +++ b/tests/app/organisation/test_rest.py @@ -26,7 +26,7 @@ from tests.app.db import ( def test_get_all_organisations(admin_request, notify_db_session): - create_organisation(name='inactive org', active=False, organisation_type='nhs_central') + create_organisation(name='inactive org', active=False, organisation_type='federal') create_organisation(name='active org', domains=['example.com']) response = admin_request.get( @@ -52,7 +52,7 @@ def test_get_all_organisations(admin_request, notify_db_session): assert response[1]['active'] is False assert response[1]['count_of_live_services'] == 0 assert response[1]['domains'] == [] - assert response[1]['organisation_type'] == 'nhs_central' + assert response[1]['organisation_type'] == 'federal' def test_get_organisation_by_id(admin_request, notify_db_session): @@ -169,7 +169,7 @@ def test_post_create_organisation(admin_request, notify_db_session, crown): 'name': 'test organisation', 'active': True, 'crown': crown, - 'organisation_type': 'local', + 'organisation_type': 'state', } response = admin_request.post( @@ -191,6 +191,7 @@ def test_post_create_organisation(admin_request, notify_db_session, crown): @pytest.mark.parametrize('org_type', ["nhs_central", "nhs_local", "nhs_gp"]) +@pytest.mark.skip(reason='Update for TTS') def test_post_create_organisation_sets_default_nhs_branding_for_nhs_orgs( admin_request, notify_db_session, nhs_email_branding, org_type ): @@ -218,7 +219,7 @@ def test_post_create_organisation_existing_name_raises_400(admin_request, sample 'name': sample_organisation.name, 'active': True, 'crown': True, - 'organisation_type': 'central', + 'organisation_type': 'federal', } response = admin_request.post( @@ -237,12 +238,12 @@ def test_post_create_organisation_existing_name_raises_400(admin_request, sample ({ 'active': False, 'crown': True, - 'organisation_type': 'central', + 'organisation_type': 'federal', }, 'name is a required property'), ({ 'active': False, 'name': 'Service name', - 'organisation_type': 'central', + 'organisation_type': 'federal', }, 'crown is a required property'), ({ 'active': False, @@ -253,7 +254,7 @@ def test_post_create_organisation_existing_name_raises_400(admin_request, sample 'active': False, 'name': 'Service name', 'crown': None, - 'organisation_type': 'central', + 'organisation_type': 'federal', }, 'crown None is not of type boolean'), ({ 'active': False, @@ -262,7 +263,7 @@ def test_post_create_organisation_existing_name_raises_400(admin_request, sample 'organisation_type': 'foo', }, ( 'organisation_type foo is not one of ' - '[central, local, nhs_central, nhs_local, nhs_gp, emergency_service, school_or_college, other]' + '[federal, state, other]' )), )) def test_post_create_organisation_with_missing_data_gives_validation_error( @@ -295,7 +296,7 @@ def test_post_update_organisation_updates_fields( 'name': 'new organisation name', 'active': False, 'crown': crown, - 'organisation_type': 'central', + 'organisation_type': 'federal', } assert org.crown is None @@ -314,7 +315,7 @@ def test_post_update_organisation_updates_fields( assert organisation[0].active == data['active'] assert organisation[0].crown == crown assert organisation[0].domains == [] - assert organisation[0].organisation_type == 'central' + assert organisation[0].organisation_type == 'federal' @pytest.mark.parametrize('domain_list', ( @@ -371,6 +372,7 @@ def test_update_other_organisation_attributes_doesnt_clear_domains( @pytest.mark.parametrize('new_org_type', ["nhs_central", "nhs_local", "nhs_gp"]) +@pytest.mark.skip(reason='Update for TTS') def test_post_update_organisation_to_nhs_type_updates_branding_if_none_present( admin_request, nhs_email_branding, @@ -398,6 +400,7 @@ def test_post_update_organisation_to_nhs_type_updates_branding_if_none_present( @pytest.mark.parametrize('new_org_type', ["nhs_central", "nhs_local", "nhs_gp"]) +@pytest.mark.skip(reason='Update for TTS') def test_post_update_organisation_to_nhs_type_does_not_update_branding_if_default_branding_set( admin_request, nhs_email_branding, @@ -581,7 +584,7 @@ def test_post_link_service_to_organisation(admin_request, sample_service): data = { 'service_id': str(sample_service.id) } - organisation = create_organisation(organisation_type='central') + organisation = create_organisation(organisation_type='federal') admin_request.post( 'organisation.link_service_to_organisation', @@ -590,7 +593,7 @@ def test_post_link_service_to_organisation(admin_request, sample_service): _expected_status=204 ) assert len(organisation.services) == 1 - assert sample_service.organisation_type == 'central' + assert sample_service.organisation_type == 'federal' @freeze_time('2021-09-24 13:30') @@ -598,7 +601,7 @@ def test_post_link_service_to_organisation_inserts_annual_billing(admin_request, data = { 'service_id': str(sample_service.id) } - organisation = create_organisation(organisation_type='central') + organisation = create_organisation(organisation_type='federal') assert len(organisation.services) == 0 assert len(AnnualBilling.query.all()) == 0 admin_request.post( @@ -623,7 +626,7 @@ def test_post_link_service_to_organisation_rollback_service_if_annual_billing_up } assert not sample_service.organisation_type - organisation = create_organisation(organisation_type='central') + organisation = create_organisation(organisation_type='federal') assert len(organisation.services) == 0 assert len(AnnualBilling.query.all()) == 0 with pytest.raises(expected_exception=SQLAlchemyError): @@ -655,7 +658,7 @@ def test_post_link_service_to_another_org( assert len(sample_organisation.services) == 1 assert not sample_service.organisation_type - new_org = create_organisation(organisation_type='central') + new_org = create_organisation(organisation_type='federal') admin_request.post( 'organisation.link_service_to_organisation', _data=data, @@ -664,7 +667,7 @@ def test_post_link_service_to_another_org( ) assert not sample_organisation.services assert len(new_org.services) == 1 - assert sample_service.organisation_type == 'central' + assert sample_service.organisation_type == 'federal' annual_billing = AnnualBilling.query.all() assert len(annual_billing) == 1 assert annual_billing[0].free_sms_fragment_limit == 150000 diff --git a/tests/app/test_commands.py b/tests/app/test_commands.py index 16b21116a..2e0c4c580 100644 --- a/tests/app/test_commands.py +++ b/tests/app/test_commands.py @@ -43,9 +43,8 @@ def test_local_dev_broadcast_permissions( @pytest.mark.parametrize("organisation_type, expected_allowance", - [('central', 40000), - ('local', 20000), - ('nhs_gp', 10000)]) + [('federal', 40000), + ('state', 40000)]) def test_populate_annual_billing_with_defaults( notify_db_session, notify_api, organisation_type, expected_allowance ):