From 3a3ef526fede1c5838be0caa979866c65b4bb4d0 Mon Sep 17 00:00:00 2001 From: eatyourpeas Date: Sat, 29 Jun 2024 18:05:59 +0100 Subject: [PATCH] remove last migration and move to seed as azure too lacklustre to build in one go --- .../hospitals/management/commands/seed.py | 6 ++++++ .../management/commands/seed_functions/__init__.py | 1 + .../commands/seed_functions/jersey.py} | 14 ++------------ 3 files changed, 9 insertions(+), 12 deletions(-) rename rcpch_nhs_organisations/hospitals/{migrations/0005_seed_jersey.py => management/commands/seed_functions/jersey.py} (69%) diff --git a/rcpch_nhs_organisations/hospitals/management/commands/seed.py b/rcpch_nhs_organisations/hospitals/management/commands/seed.py index 4dc46bf..0b68d0d 100644 --- a/rcpch_nhs_organisations/hospitals/management/commands/seed.py +++ b/rcpch_nhs_organisations/hospitals/management/commands/seed.py @@ -9,6 +9,7 @@ seed_trusts, seed_pdus, ods_codes_to_abstraction_levels, + load_jersey_boundaries, ) from .image import rcpch_ascii_art @@ -46,6 +47,10 @@ def handle(self, *args, **options): self.stdout.write(B + "Adding paediatric diabetes units..." + W) seed_pdus() rcpch_ascii_art() + elif options["model"] == "jersey": + self.stdout.write(B + "Adding Jersey boundaries..." + W) + load_jersey_boundaries() + rcpch_ascii_art() elif options["model"] == "all": self.stdout.write( B + "Adding all organisations and levels of abstraction..." + W @@ -54,6 +59,7 @@ def handle(self, *args, **options): seed_trusts() seed_organisations() seed_pdus() + load_jersey_boundaries() rcpch_ascii_art() else: diff --git a/rcpch_nhs_organisations/hospitals/management/commands/seed_functions/__init__.py b/rcpch_nhs_organisations/hospitals/management/commands/seed_functions/__init__.py index 154a6d8..44f4ce3 100644 --- a/rcpch_nhs_organisations/hospitals/management/commands/seed_functions/__init__.py +++ b/rcpch_nhs_organisations/hospitals/management/commands/seed_functions/__init__.py @@ -1,4 +1,5 @@ from .abstraction_levels import * +from .jersey import * from .organisations import * from .pdus import * from .trusts import * diff --git a/rcpch_nhs_organisations/hospitals/migrations/0005_seed_jersey.py b/rcpch_nhs_organisations/hospitals/management/commands/seed_functions/jersey.py similarity index 69% rename from rcpch_nhs_organisations/hospitals/migrations/0005_seed_jersey.py rename to rcpch_nhs_organisations/hospitals/management/commands/seed_functions/jersey.py index 378fe7e..c910579 100644 --- a/rcpch_nhs_organisations/hospitals/migrations/0005_seed_jersey.py +++ b/rcpch_nhs_organisations/hospitals/management/commands/seed_functions/jersey.py @@ -1,4 +1,3 @@ -from django.db import migrations from django.apps import apps as django_apps import os @@ -10,8 +9,8 @@ Jersey_Boundary_File = os.path.join(app_path, "shape_files", "Jersey", "CLC06_UK.shp") -def load_jersey_boundaries(apps, schema_editor, verbose=True): - JerseyBoundaries = apps.get_model("hospitals", "JerseyBoundaries") +def load_jersey_boundaries(): + JerseyBoundaries = django_apps.get_model("hospitals", "JerseyBoundaries") jerseyboundaries_mapping = { "objectid": "OBJECTID", "shape_id": "ID", @@ -30,12 +29,3 @@ def load_jersey_boundaries(apps, schema_editor, verbose=True): encoding="iso-8859-1", ) lm.save(strict=True, verbose=True) - - -class Migration(migrations.Migration): - - dependencies = [ - ("hospitals", "0004_jerseyboundaries"), - ] - - operations = [migrations.RunPython(load_jersey_boundaries)]