From 36746729ec55c4fc91bd9edcf18f8da984c8eda8 Mon Sep 17 00:00:00 2001 From: Dana Lambert Date: Tue, 7 Dec 2021 10:39:30 +1300 Subject: [PATCH] Update ChristchurchZone model name to ChristchurchRegion --- backend/right_tree/api/admin.py | 2 +- backend/right_tree/api/filters.py | 4 ++-- .../api/management/commands/loadshapefiles.py | 12 ++++++------ ...hristchurchzone.py => 0010_christchurchregion.py} | 4 ++-- backend/right_tree/api/models.py | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) rename backend/right_tree/api/migrations/{0010_christchurchzone.py => 0010_christchurchregion.py} (87%) diff --git a/backend/right_tree/api/admin.py b/backend/right_tree/api/admin.py index 03d100d..0af29dd 100644 --- a/backend/right_tree/api/admin.py +++ b/backend/right_tree/api/admin.py @@ -22,4 +22,4 @@ admin.site.register(models.HabitatImage) admin.site.register(models.Habitat) admin.site.register(models.Zone, ZoneAdmin) admin.site.register(models.ZoneImageSegment, ZoneImageSegmentAdmin) -admin.site.register(models.ChristchurchZone) +admin.site.register(models.ChristchurchRegion) diff --git a/backend/right_tree/api/filters.py b/backend/right_tree/api/filters.py index ffde0af..ee5f988 100644 --- a/backend/right_tree/api/filters.py +++ b/backend/right_tree/api/filters.py @@ -3,7 +3,7 @@ import json from django.http import Http404 from django.db.models import Q -from .models import Plant, EcologicalRegion, EcologicalDistrictLayer, ChristchurchZone, SoilOrder, SoilVariant +from .models import Plant, EcologicalRegion, EcologicalDistrictLayer, ChristchurchRegion, SoilOrder, SoilVariant from .wms_utils import get_point_from_coordinates @@ -67,7 +67,7 @@ def is_in_auckland(coordinates): def is_in_christchurch(coordinates): pnt = get_point_from_coordinates(coordinates) - in_chch = ChristchurchZone.objects.filter(geom__intersects=pnt).first() + in_chch = ChristchurchRegion.objects.filter(geom__intersects=pnt).first() return in_chch is not None; def get_filtered_plants(request): diff --git a/backend/right_tree/api/management/commands/loadshapefiles.py b/backend/right_tree/api/management/commands/loadshapefiles.py index 250fc81..0800034 100644 --- a/backend/right_tree/api/management/commands/loadshapefiles.py +++ b/backend/right_tree/api/management/commands/loadshapefiles.py @@ -4,7 +4,7 @@ from django.contrib.gis.utils import LayerMapping from pathlib import Path import right_tree.api.data -from right_tree.api.models import SoilLayer, EcologicalDistrictLayer, ChristchurchZone +from right_tree.api.models import SoilLayer, EcologicalDistrictLayer, ChristchurchRegion # Auto-generated `LayerMapping` dictionary for SoilLayers model soillayer_mapping = { @@ -25,8 +25,8 @@ ecologicaldistrictlayer_mapping = { 'geom': 'POLYGON', } -# Auto-generated `LayerMapping` dictionary for ChristchurchZone model -christchurchzone_mapping = { +# Auto-generated `LayerMapping` dictionary for ChristchurchRegion model +christchurchregion_mapping = { 'objectid': 'OBJECTID', 'name': 'NAME', 'geom': 'MULTIPOLYGON', @@ -35,7 +35,7 @@ christchurchzone_mapping = { # Shapefiles soillayer_shp = Path(right_tree.api.data.__file__).resolve().parent / 'resources' / 'fundamental_soil_layers' / 'fundamental-soil-layers-new-zealand-soil-classification.shp' ecologicaldistrictlayer_shp = Path(right_tree.api.data.__file__).resolve().parent / 'resources' / 'ecological_districts' / 'DOC_EcologicalDistricts_2021_08_02.shp' -christchurchzone_shp = Path(right_tree.api.data.__file__).resolve().parent / 'resources' / 'chch_zone' / 'Greater_Christchurch_Area.shp' +christchurchregion_shp = Path(right_tree.api.data.__file__).resolve().parent / 'resources' / 'chch_zone' / 'Greater_Christchurch_Area.shp' class Command(BaseCommand): help = 'Ingests the shapefile data for ecological regions and soil layers.' @@ -52,6 +52,6 @@ class Command(BaseCommand): self.stdout.write(self.style.SUCCESS('Ecological district layers loaded succesfully.')) self.stdout.write('Loading christchurch zone layer...') - christchurchzonelayer_lm = LayerMapping(ChristchurchZone, christchurchzone_shp, christchurchzone_mapping, transform=False) - christchurchzonelayer_lm.save(strict=True) + christchurchregionlayer_lm = LayerMapping(ChristchurchRegion, christchurchregion_shp, christchurchregion_mapping, transform=False) + christchurchregionlayer_lm.save(strict=True) self.stdout.write(self.style.SUCCESS(' Christchurch zone layer loaded succesfully.')) diff --git a/backend/right_tree/api/migrations/0010_christchurchzone.py b/backend/right_tree/api/migrations/0010_christchurchregion.py similarity index 87% rename from backend/right_tree/api/migrations/0010_christchurchzone.py rename to backend/right_tree/api/migrations/0010_christchurchregion.py index 04e165a..917537e 100644 --- a/backend/right_tree/api/migrations/0010_christchurchzone.py +++ b/backend/right_tree/api/migrations/0010_christchurchregion.py @@ -1,4 +1,4 @@ -# Generated by Django 3.2.8 on 2021-11-30 00:40 +# Generated by Django 3.2.8 on 2021-12-06 21:36 import django.contrib.gis.db.models.fields from django.db import migrations, models @@ -12,7 +12,7 @@ class Migration(migrations.Migration): operations = [ migrations.CreateModel( - name='ChristchurchZone', + name='ChristchurchRegion', fields=[ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('objectid', models.IntegerField()), diff --git a/backend/right_tree/api/models.py b/backend/right_tree/api/models.py index d50d182..ada7597 100644 --- a/backend/right_tree/api/models.py +++ b/backend/right_tree/api/models.py @@ -46,7 +46,7 @@ class EcologicalDistrictLayer(models.Model): return f"{self.ecologic_1} ({self.ecologic_2})" -class ChristchurchZone(models.Model): +class ChristchurchRegion(models.Model): objectid = models.IntegerField() name = models.CharField(max_length=25) geom = models.MultiPolygonField(srid=2193)