Fixes and improvements
This commit is contained in:
parent
436075f11c
commit
c1796c22a6
12 changed files with 199 additions and 67 deletions
|
@ -3,7 +3,7 @@
|
|||
"model": "api.ecologicalregion",
|
||||
"pk": 1,
|
||||
"fields": {
|
||||
"name": "Aorrangi"
|
||||
"name": "Aorangi"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -549,7 +549,7 @@
|
|||
"model": "api.ecologicalregion",
|
||||
"pk": 79,
|
||||
"fields": {
|
||||
"name": "Whatkatane"
|
||||
"name": "Whakatane"
|
||||
}
|
||||
}
|
||||
]
|
||||
]
|
||||
|
|
BIN
backend/right_tree/api/data/resources/plant_data.xlsx
Normal file
BIN
backend/right_tree/api/data/resources/plant_data.xlsx
Normal file
Binary file not shown.
|
@ -1,7 +1,9 @@
|
|||
from django.core.management.base import BaseCommand
|
||||
from django.contrib.gis.utils import LayerMapping
|
||||
|
||||
from glob import iglob
|
||||
from pathlib import Path
|
||||
from zipfile import ZipFile, is_zipfile
|
||||
|
||||
import right_tree.api.data
|
||||
from right_tree.api.models import SoilLayer, EcologicalDistrictLayer, ChristchurchRegion
|
||||
|
@ -32,15 +34,24 @@ christchurchregion_mapping = {
|
|||
'geom': 'MULTIPOLYGON',
|
||||
}
|
||||
|
||||
# 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'
|
||||
christchurchregion_shp = Path(right_tree.api.data.__file__).resolve().parent / 'resources' / 'chch_zone' / 'Greater_Christchurch_Area.shp'
|
||||
resources_path = Path(right_tree.api.data.__file__).resolve().parent / "resources"
|
||||
|
||||
soillayer_shp = resources_path / "fundamental-soil-layers-new-zealand-soil-classification.shp"
|
||||
ecologicaldistrictlayer_shp = resources_path / "Ecological_Districts.shp"
|
||||
christchurchregion_shp = resources_path / "Greater_Christchurch_Area.shp"
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = 'Ingests the shapefile data for ecological regions and soil layers.'
|
||||
|
||||
def handle(self, *args, **options):
|
||||
query = str(resources_path / "*.zip")
|
||||
sources = [ZipFile(path) for path in iglob(query) if is_zipfile(path)]
|
||||
|
||||
for zf in sources:
|
||||
zf.extractall(resources_path)
|
||||
zf.close()
|
||||
|
||||
self.stdout.write('Loading soil layers...')
|
||||
soil_lm = LayerMapping(SoilLayer, soillayer_shp, soillayer_mapping, transform=False)
|
||||
soil_lm.save(strict=True)
|
||||
|
|
|
@ -27,7 +27,7 @@ SECRET_KEY = os.getenv("DJANGO_SECRET_KEY", 'django-insecure-5t05qc2&14xuot4lgs#
|
|||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = os.getenv('DJANGO_DEBUG_MODE', '') != 'False'
|
||||
|
||||
# os.getenv("ALLOWED_HOSTS", "").split(","),
|
||||
# os.getenv("ALLOWED_HOSTS", "").split(","),
|
||||
ALLOWED_HOSTS = [BASE_URL, "localhost"]
|
||||
|
||||
|
||||
|
@ -85,11 +85,11 @@ WSGI_APPLICATION = 'right_tree.wsgi.application'
|
|||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.contrib.gis.db.backends.postgis',
|
||||
'NAME': os.getenv("RIGHTTREE_DB", "postgres"),
|
||||
'USER': os.getenv("RIGHTTREE_DB_USER", "postgres"),
|
||||
'PASSWORD': os.getenv("RIGHTTREE_DB_PASSWORD", "postgres"),
|
||||
'HOST': "postgres",
|
||||
'PORT': 5432,
|
||||
'NAME': os.getenv("DATABASE_NAME", "righttree"),
|
||||
'USER': os.getenv("DATABASE_USER", "righttree"),
|
||||
'PASSWORD': os.getenv("DATABASE_PASSWORD", "righttree"),
|
||||
'HOST': os.getenv("DATABASE_HOST", "postgres"),
|
||||
'PORT': int(os.getenv("DATABASE_PORT", 5432)),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -139,13 +139,6 @@ STATIC_ROOT = os.path.join(PROJECT_DIR, 'staticfiles')
|
|||
|
||||
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
||||
|
||||
frontend_url = os.getenv('FRONTEND_BASE_URL', 'localhost:3000')
|
||||
|
||||
CORS_ALLOWED_ORIGINS = [
|
||||
f"https://{frontend_url}",
|
||||
f"http://{frontend_url}"
|
||||
]
|
||||
|
||||
CORS_ALLOW_HEADERS = [
|
||||
'access-control-allow-origin'
|
||||
]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue