From 325f65dc9b881c05f13fe15477f4ea114a2ac885 Mon Sep 17 00:00:00 2001 From: George Silva Date: Thu, 29 Aug 2024 14:18:09 -0300 Subject: [PATCH] remove boundary app --- .../{boundary => acvitites}/__init__.py | 0 src/planscape/acvitites/serializers.py | 1 + .../__init__.py => acvitites/views.py} | 0 src/planscape/boundary/admin.py | 3 - src/planscape/boundary/apps.py | 6 -- ...ndary_display_name_boundary_region_name.py | 69 ------------------- src/planscape/boundary/models.py | 26 ------- src/planscape/boundary/serializers.py | 17 ----- src/planscape/boundary/urls.py | 8 --- src/planscape/boundary/views.py | 36 ---------- src/planscape/planscape/settings.py | 1 - src/planscape/planscape/urls.py | 2 - 12 files changed, 1 insertion(+), 168 deletions(-) rename src/planscape/{boundary => acvitites}/__init__.py (100%) create mode 100644 src/planscape/acvitites/serializers.py rename src/planscape/{boundary/migrations/__init__.py => acvitites/views.py} (100%) delete mode 100644 src/planscape/boundary/admin.py delete mode 100644 src/planscape/boundary/apps.py delete mode 100644 src/planscape/boundary/migrations/0001_squashed_0002_boundary_display_name_boundary_region_name.py delete mode 100644 src/planscape/boundary/models.py delete mode 100644 src/planscape/boundary/serializers.py delete mode 100644 src/planscape/boundary/urls.py delete mode 100644 src/planscape/boundary/views.py diff --git a/src/planscape/boundary/__init__.py b/src/planscape/acvitites/__init__.py similarity index 100% rename from src/planscape/boundary/__init__.py rename to src/planscape/acvitites/__init__.py diff --git a/src/planscape/acvitites/serializers.py b/src/planscape/acvitites/serializers.py new file mode 100644 index 000000000..93831062a --- /dev/null +++ b/src/planscape/acvitites/serializers.py @@ -0,0 +1 @@ +from actstream.models import user_stream, target_stream diff --git a/src/planscape/boundary/migrations/__init__.py b/src/planscape/acvitites/views.py similarity index 100% rename from src/planscape/boundary/migrations/__init__.py rename to src/planscape/acvitites/views.py diff --git a/src/planscape/boundary/admin.py b/src/planscape/boundary/admin.py deleted file mode 100644 index 8c38f3f3d..000000000 --- a/src/planscape/boundary/admin.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.contrib import admin - -# Register your models here. diff --git a/src/planscape/boundary/apps.py b/src/planscape/boundary/apps.py deleted file mode 100644 index a1bf3582a..000000000 --- a/src/planscape/boundary/apps.py +++ /dev/null @@ -1,6 +0,0 @@ -from django.apps import AppConfig - - -class BoundaryConfig(AppConfig): - default_auto_field = "django.db.models.BigAutoField" - name = "boundary" diff --git a/src/planscape/boundary/migrations/0001_squashed_0002_boundary_display_name_boundary_region_name.py b/src/planscape/boundary/migrations/0001_squashed_0002_boundary_display_name_boundary_region_name.py deleted file mode 100644 index 60a5eead3..000000000 --- a/src/planscape/boundary/migrations/0001_squashed_0002_boundary_display_name_boundary_region_name.py +++ /dev/null @@ -1,69 +0,0 @@ -# Generated by Django 4.1.1 on 2022-10-30 22:55 - -import django.contrib.gis.db.models.fields -from django.db import migrations, models -import django.db.models.deletion -from typing import Tuple - - -class Migration(migrations.Migration): - replaces = [ - ("boundary", "0001_initial"), - ("boundary", "0002_boundary_display_name_boundary_region_name"), - ] - - initial = True - - dependencies: list[Tuple[str, str]] = [] - - operations = [ - migrations.CreateModel( - name="Boundary", - fields=[ - ( - "id", - models.BigAutoField( - auto_created=True, - primary_key=True, - serialize=False, - verbose_name="ID", - ), - ), - ("boundary_name", models.CharField(max_length=120)), - ("display_name", models.CharField(max_length=120, null=True)), - ("region_name", models.CharField(max_length=120, null=True)), - ], - ), - migrations.CreateModel( - name="BoundaryDetails", - fields=[ - ( - "id", - models.BigAutoField( - auto_created=True, - primary_key=True, - serialize=False, - verbose_name="ID", - ), - ), - ( - "geometry", - django.contrib.gis.db.models.fields.MultiPolygonField( - null=True, srid=4269 - ), - ), - ("objectid", models.BigIntegerField(null=True)), - ("shape_name", models.CharField(max_length=120, null=True)), - ("states", models.CharField(max_length=50, null=True)), - ("hectares", models.FloatField(null=True)), - ("acres", models.FloatField(null=True)), - ( - "boundary", - models.ForeignKey( - on_delete=django.db.models.deletion.CASCADE, - to="boundary.boundary", - ), - ), - ], - ), - ] diff --git a/src/planscape/boundary/models.py b/src/planscape/boundary/models.py deleted file mode 100644 index 83a0473fe..000000000 --- a/src/planscape/boundary/models.py +++ /dev/null @@ -1,26 +0,0 @@ -from django.contrib.gis.db import models - - -class Boundary(models.Model): - """A Boundary object is a collection of polygons with a name.""" - - boundary_name: models.CharField = models.CharField(max_length=120) - # Optional fields for Boundary - display_name: models.CharField = models.CharField(max_length=120, null=True) - region_name: models.CharField = models.CharField(max_length=120, null=True) - - -class BoundaryDetails(models.Model): - """ - A BoundaryDetails Model object is a single polygon, referencing the Boundary - object, with additional metadata. - """ - - boundary = models.ForeignKey(Boundary, on_delete=models.CASCADE) # type: ignore - geometry = models.MultiPolygonField(srid=4269, null=True) - # Optional fields for boundary areas - objectid: models.BigIntegerField = models.BigIntegerField(null=True) - shape_name: models.CharField = models.CharField(max_length=120, null=True) - states: models.CharField = models.CharField(max_length=50, null=True) - acres: models.FloatField = models.FloatField(null=True) - hectares: models.FloatField = models.FloatField(null=True) diff --git a/src/planscape/boundary/serializers.py b/src/planscape/boundary/serializers.py deleted file mode 100644 index 4c275f853..000000000 --- a/src/planscape/boundary/serializers.py +++ /dev/null @@ -1,17 +0,0 @@ -from rest_framework_gis import serializers -from .models import Boundary, BoundaryDetails - - -class BoundarySerializer(serializers.ModelSerializer): - class Meta: - fields = ("id", "boundary_name", "display_name", "region_name") - model = Boundary - - -class BoundaryDetailsSerializer(serializers.GeoFeatureModelSerializer): - clipped_geometry = serializers.GeometryField() - - class Meta: - fields = ("id", "shape_name") - geo_field = "clipped_geometry" - model = BoundaryDetails diff --git a/src/planscape/boundary/urls.py b/src/planscape/boundary/urls.py deleted file mode 100644 index 665c42814..000000000 --- a/src/planscape/boundary/urls.py +++ /dev/null @@ -1,8 +0,0 @@ -from django.urls import path -from . import views - -app_name = "boundary" - -urlpatterns = [ - path("config/", views.config), -] diff --git a/src/planscape/boundary/views.py b/src/planscape/boundary/views.py deleted file mode 100644 index 46c2e16c5..000000000 --- a/src/planscape/boundary/views.py +++ /dev/null @@ -1,36 +0,0 @@ -import json -import logging -import os - - -from django.http import ( - HttpRequest, - HttpResponse, - JsonResponse, - QueryDict, -) - -from django.conf import settings - -# Configure global logging. -logger = logging.getLogger(__name__) - - -def get_config(params: QueryDict): - assert isinstance(params["region_name"], str) - region_name = params["region_name"] - - # Read from boundary config - config_path = os.path.join(settings.BASE_DIR, "config/boundary.json") - boundary_config = json.load(open(config_path, "r")) - - for region in boundary_config["regions"]: - if region_name == region["region_name"]: - return region["boundaries"] - - return None - - -def config(request: HttpRequest) -> HttpResponse: - boundary = get_config(request.GET) - return JsonResponse(boundary, safe=False) diff --git a/src/planscape/planscape/settings.py b/src/planscape/planscape/settings.py index 100ea9bb7..d96dc80ee 100644 --- a/src/planscape/planscape/settings.py +++ b/src/planscape/planscape/settings.py @@ -32,7 +32,6 @@ # Application definition planscape_apps = [ - "boundary", "collaboration", "conditions", "core", diff --git a/src/planscape/planscape/urls.py b/src/planscape/planscape/urls.py index 1ded14a51..94c26feec 100644 --- a/src/planscape/planscape/urls.py +++ b/src/planscape/planscape/urls.py @@ -9,8 +9,6 @@ register_converter(ContentTypeURLConverter, "ctype") urlpatterns = [ - # path("planscape-backend/admin/", admin.site.urls), - path("planscape-backend/boundary/", include("boundary.urls")), path("planscape-backend/conditions/", include("conditions.urls")), path("planscape-backend/planning/", include("planning.urls")), path(