From 02bc87c096bc9bdee508735cb5d43737d885b462 Mon Sep 17 00:00:00 2001 From: Pea Tyczynska Date: Mon, 1 Feb 2021 14:43:25 +0000 Subject: [PATCH 1/3] Add billing details and notes for organisation table --- app/models.py | 6 ++ .../versions/0343_org_billing_details.py | 65 +++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 migrations/versions/0343_org_billing_details.py diff --git a/app/models.py b/app/models.py index 0e2b6db61..c8e6215b1 100644 --- a/app/models.py +++ b/app/models.py @@ -397,6 +397,12 @@ class Organisation(db.Model): nullable=True, ) + notes = db.Column(db.Text, nullable=True) + purchase_order_number = db.Column(db.String(255), nullable=True) + billing_contact_names = db.Column(db.Text, nullable=True) + billing_contact_email_addresses = db.Column(db.Text, nullable=True) + billing_reference = db.Column(db.String(255), nullable=True) + @property def live_services(self): return [ diff --git a/migrations/versions/0343_org_billing_details.py b/migrations/versions/0343_org_billing_details.py new file mode 100644 index 000000000..dcdf50d5c --- /dev/null +++ b/migrations/versions/0343_org_billing_details.py @@ -0,0 +1,65 @@ +""" + +Revision ID: 0343_org_billing_details +Revises: 0342_service_broadcast_settings +Create Date: 2021-02-01 14:40:14.809632 + +""" +from alembic import op +import sqlalchemy as sa + + +revision = '0343_org_billing_details' +down_revision = '0342_service_broadcast_settings' + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.add_column('organisation', sa.Column('billing_contact_email_addresses', sa.Text(), nullable=True)) + op.add_column('organisation', sa.Column('billing_contact_names', sa.Text(), nullable=True)) + op.add_column('organisation', sa.Column('billing_reference', sa.String(length=255), nullable=True)) + op.add_column('organisation', sa.Column('notes', sa.Text(), nullable=True)) + op.add_column('organisation', sa.Column('purchase_order_number', sa.String(length=255), nullable=True)) + op.alter_column('services', 'billing_contact_email_addresses', + existing_type=sa.VARCHAR(length=255), + type_=sa.Text(), + existing_nullable=True) + op.alter_column('services', 'billing_contact_names', + existing_type=sa.VARCHAR(length=255), + type_=sa.Text(), + existing_nullable=True) + op.alter_column('services_history', 'billing_contact_email_addresses', + existing_type=sa.VARCHAR(length=255), + type_=sa.Text(), + existing_nullable=True) + op.alter_column('services_history', 'billing_contact_names', + existing_type=sa.VARCHAR(length=255), + type_=sa.Text(), + existing_nullable=True) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.alter_column('services_history', 'billing_contact_names', + existing_type=sa.Text(), + type_=sa.VARCHAR(length=255), + existing_nullable=True) + op.alter_column('services_history', 'billing_contact_email_addresses', + existing_type=sa.Text(), + type_=sa.VARCHAR(length=255), + existing_nullable=True) + op.alter_column('services', 'billing_contact_names', + existing_type=sa.Text(), + type_=sa.VARCHAR(length=255), + existing_nullable=True) + op.alter_column('services', 'billing_contact_email_addresses', + existing_type=sa.Text(), + type_=sa.VARCHAR(length=255), + existing_nullable=True) + op.drop_column('organisation', 'purchase_order_number') + op.drop_column('organisation', 'notes') + op.drop_column('organisation', 'billing_reference') + op.drop_column('organisation', 'billing_contact_names') + op.drop_column('organisation', 'billing_contact_email_addresses') + # ### end Alembic commands ### From aa7bc3d9b402c7cf864acb3c66b11b405bcba06f Mon Sep 17 00:00:00 2001 From: Pea Tyczynska Date: Thu, 4 Feb 2021 17:33:46 +0000 Subject: [PATCH 2/3] Serialise org notes and billing details --- app/models.py | 5 +++++ tests/app/organisation/test_rest.py | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/app/models.py b/app/models.py index c8e6215b1..26b9e2e30 100644 --- a/app/models.py +++ b/app/models.py @@ -434,6 +434,11 @@ class Organisation(db.Model): "domains": self.domain_list, "request_to_go_live_notes": self.request_to_go_live_notes, "count_of_live_services": len(self.live_services), + "notes": self.notes, + "purchase_order_number": self.purchase_order_number, + "billing_contact_names": self.billing_contact_names, + "billing_contact_email_addresses": self.billing_contact_email_addresses, + "billing_reference": self.billing_reference, } def serialize_for_list(self): diff --git a/tests/app/organisation/test_rest.py b/tests/app/organisation/test_rest.py index 0fce3ef8b..2fb52d338 100644 --- a/tests/app/organisation/test_rest.py +++ b/tests/app/organisation/test_rest.py @@ -77,6 +77,11 @@ def test_get_organisation_by_id(admin_request, notify_db_session): 'domains', 'request_to_go_live_notes', 'count_of_live_services', + 'notes', + 'billing_contact_names', + 'billing_contact_email_addresses', + 'billing_reference', + 'purchase_order_number' } assert response['id'] == str(org.id) assert response['name'] == 'test_org_1' @@ -93,6 +98,11 @@ def test_get_organisation_by_id(admin_request, notify_db_session): assert response['count_of_live_services'] == 0 assert response['agreement_signed_on_behalf_of_name'] is None assert response['agreement_signed_on_behalf_of_email_address'] is None + assert response['notes'] is None + assert response['billing_contact_names'] is None + assert response['billing_contact_email_addresses'] is None + assert response['billing_reference'] is None + assert response['purchase_order_number'] is None def test_get_organisation_by_id_returns_domains(admin_request, notify_db_session): From bbc8cffb5b944b09855191d6bbdfb5c6e59f2770 Mon Sep 17 00:00:00 2001 From: Pea Tyczynska Date: Mon, 8 Feb 2021 10:45:28 +0000 Subject: [PATCH 3/3] No need to alter the columns in services, they are already the right type --- .../versions/0343_org_billing_details.py | 32 ------------------- 1 file changed, 32 deletions(-) diff --git a/migrations/versions/0343_org_billing_details.py b/migrations/versions/0343_org_billing_details.py index dcdf50d5c..e99a3d219 100644 --- a/migrations/versions/0343_org_billing_details.py +++ b/migrations/versions/0343_org_billing_details.py @@ -20,43 +20,11 @@ def upgrade(): op.add_column('organisation', sa.Column('billing_reference', sa.String(length=255), nullable=True)) op.add_column('organisation', sa.Column('notes', sa.Text(), nullable=True)) op.add_column('organisation', sa.Column('purchase_order_number', sa.String(length=255), nullable=True)) - op.alter_column('services', 'billing_contact_email_addresses', - existing_type=sa.VARCHAR(length=255), - type_=sa.Text(), - existing_nullable=True) - op.alter_column('services', 'billing_contact_names', - existing_type=sa.VARCHAR(length=255), - type_=sa.Text(), - existing_nullable=True) - op.alter_column('services_history', 'billing_contact_email_addresses', - existing_type=sa.VARCHAR(length=255), - type_=sa.Text(), - existing_nullable=True) - op.alter_column('services_history', 'billing_contact_names', - existing_type=sa.VARCHAR(length=255), - type_=sa.Text(), - existing_nullable=True) # ### end Alembic commands ### def downgrade(): # ### commands auto generated by Alembic - please adjust! ### - op.alter_column('services_history', 'billing_contact_names', - existing_type=sa.Text(), - type_=sa.VARCHAR(length=255), - existing_nullable=True) - op.alter_column('services_history', 'billing_contact_email_addresses', - existing_type=sa.Text(), - type_=sa.VARCHAR(length=255), - existing_nullable=True) - op.alter_column('services', 'billing_contact_names', - existing_type=sa.Text(), - type_=sa.VARCHAR(length=255), - existing_nullable=True) - op.alter_column('services', 'billing_contact_email_addresses', - existing_type=sa.Text(), - type_=sa.VARCHAR(length=255), - existing_nullable=True) op.drop_column('organisation', 'purchase_order_number') op.drop_column('organisation', 'notes') op.drop_column('organisation', 'billing_reference')