Skip to content

Commit

Permalink
EAS-2491 Remove deprecated Organisation fields (#171)
Browse files Browse the repository at this point in the history
* initial cull of deprecated params to classes & methods

* fix tests and column constraints

* fix migration file conflict

* fix template test

* fix tests to work with reduced permission set

* fix tests to work with reduced permission set

* fix permissions on tests

* fix tests

* fix config for migrations to work

* remove commented-out code

* remove commented-out code

* remove references to unused var

* add migration file to remove deprecated org fields

* remove org columns
  • Loading branch information
jonathan-owens-gds authored Dec 4, 2024
1 parent 0dc0a20 commit 8460fa0
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 41 deletions.
1 change: 0 additions & 1 deletion app/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ def boolean_or_none(field):
data = {
"name": columns[0],
"active": True,
"agreement_signed": boolean_or_none(columns[3]),
"crown": boolean_or_none(columns[2]),
"organisation_type": columns[1].lower(),
}
Expand Down
21 changes: 0 additions & 21 deletions app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,15 +215,13 @@ class Domain(db.Model):

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):
__tablename__ = "organisation_types"

name = db.Column(db.String(255), primary_key=True)
is_crown = db.Column(db.Boolean, nullable=True)
annual_free_sms_fragment_limit = db.Column(db.BigInteger, nullable=False)


class Organisation(db.Model):
Expand All @@ -233,25 +231,13 @@ class Organisation(db.Model):
active = db.Column(db.Boolean, nullable=False, default=True)
created_at = db.Column(db.DateTime, nullable=False, default=datetime.datetime.utcnow)
updated_at = db.Column(db.DateTime, nullable=True, onupdate=datetime.datetime.utcnow)
agreement_signed = db.Column(db.Boolean, nullable=True)
agreement_signed_at = db.Column(db.DateTime, nullable=True)
agreement_signed_by_id = db.Column(
UUID(as_uuid=True),
db.ForeignKey("users.id"),
nullable=True,
)
agreement_signed_by = db.relationship("User")
agreement_signed_on_behalf_of_name = db.Column(db.String(255), nullable=True)
agreement_signed_on_behalf_of_email_address = db.Column(db.String(255), nullable=True)
agreement_signed_version = db.Column(db.Float, nullable=True)
crown = db.Column(db.Boolean, nullable=True)
organisation_type = db.Column(
db.String(255),
db.ForeignKey("organisation_types.name"),
unique=False,
nullable=True,
)
request_to_go_live_notes = db.Column(db.Text)

domains = db.relationship(
"Domain",
Expand All @@ -274,14 +260,7 @@ def serialize(self):
"active": self.active,
"crown": self.crown,
"organisation_type": self.organisation_type,
"agreement_signed": self.agreement_signed,
"agreement_signed_at": self.agreement_signed_at,
"agreement_signed_by_id": self.agreement_signed_by_id,
"agreement_signed_on_behalf_of_name": self.agreement_signed_on_behalf_of_name,
"agreement_signed_on_behalf_of_email_address": self.agreement_signed_on_behalf_of_email_address,
"agreement_signed_version": self.agreement_signed_version,
"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,
}
Expand Down
32 changes: 32 additions & 0 deletions migrations/versions/0405_drop_notify_org_fields.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"""
Revision ID: 0405_drop_notify_org_fields
Revises: 0404_drop_constraints
Create Date: 2024-12-02 10:00:00
"""

from alembic import op

revision = "0405_drop_notify_org_fields"
down_revision = "0404_drop_constraints"


def upgrade():
op.drop_column("organisation", "agreement_signed")
op.drop_column("organisation", "agreement_signed_at")
op.drop_column("organisation", "agreement_signed_by_id")
op.drop_column("organisation", "agreement_signed_version")
op.drop_column("organisation", "request_to_go_live_notes")
op.drop_column("organisation", "agreement_signed_on_behalf_of_email_address")
op.drop_column("organisation", "agreement_signed_on_behalf_of_name")
op.drop_column("organisation", "billing_contact_email_addresses")
op.drop_column("organisation", "billing_contact_names")
op.drop_column("organisation", "billing_reference")
op.drop_column("organisation", "purchase_order_number")

op.drop_column("organisation_types", "annual_free_sms_fragment_limit")


def downgrade():
pass
6 changes: 0 additions & 6 deletions tests/app/dao/test_organisation_dao.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import datetime
import uuid

import pytest
Expand Down Expand Up @@ -56,16 +55,11 @@ def test_update_organisation(notify_db_session):
create_organisation()

organisation = Organisation.query.one()
user = create_user()

data = {
"name": "new name",
"crown": True,
"organisation_type": "local",
"agreement_signed": True,
"agreement_signed_at": datetime.datetime.utcnow(),
"agreement_signed_by_id": user.id,
"agreement_signed_version": 999.99,
}

for attribute, value in data.items():
Expand Down
13 changes: 0 additions & 13 deletions tests/app/organisation/test_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,7 @@ def test_get_organisation_by_id(admin_request, notify_db_session):
"active",
"crown",
"organisation_type",
"agreement_signed",
"agreement_signed_at",
"agreement_signed_by_id",
"agreement_signed_version",
"agreement_signed_on_behalf_of_name",
"agreement_signed_on_behalf_of_email_address",
"domains",
"request_to_go_live_notes",
"count_of_live_services",
"notes",
}
Expand All @@ -74,14 +67,8 @@ def test_get_organisation_by_id(admin_request, notify_db_session):
assert response["active"] is True
assert response["crown"] is None
assert response["organisation_type"] is None
assert response["agreement_signed"] is None
assert response["agreement_signed_by_id"] is None
assert response["agreement_signed_version"] is None
assert response["domains"] == []
assert response["request_to_go_live_notes"] is None
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


Expand Down

0 comments on commit 8460fa0

Please sign in to comment.