From ebe149b7c34389a62f36bd91191c812edc607d19 Mon Sep 17 00:00:00 2001 From: robinvandermolen Date: Thu, 21 Nov 2024 11:16:26 +0100 Subject: [PATCH] :sparkles: [#2173] Add map tile layer admin configuration --- src/openforms/config/admin.py | 16 +++++- .../config/migrations/0069_maptilelayer.py | 56 +++++++++++++++++++ src/openforms/config/models/__init__.py | 2 + src/openforms/config/models/map.py | 35 ++++++++++++ .../fixtures/admin_index_unlisted.json | 1 + 5 files changed, 109 insertions(+), 1 deletion(-) create mode 100644 src/openforms/config/migrations/0069_maptilelayer.py create mode 100644 src/openforms/config/models/map.py diff --git a/src/openforms/config/admin.py b/src/openforms/config/admin.py index b050ba22af..a1b2fd1764 100644 --- a/src/openforms/config/admin.py +++ b/src/openforms/config/admin.py @@ -9,7 +9,7 @@ from .admin_views import ThemePreviewView from .forms import GlobalConfigurationAdminForm, ThemeAdminForm -from .models import CSPSetting, GlobalConfiguration, RichTextColor, Theme +from .models import CSPSetting, GlobalConfiguration, MapTileLayer, RichTextColor, Theme @admin.register(GlobalConfiguration) @@ -221,6 +221,20 @@ class RichTextColorAdmin(admin.ModelAdmin): ] +@admin.register(MapTileLayer) +class MapTileLayerAdmin(admin.ModelAdmin): + fields = [ + "label", + "identifier", + "url", + ] + list_display = [ + "label", + "identifier", + "url", + ] + + @admin.register(CSPSetting) class CSPSettingAdmin(admin.ModelAdmin): readonly_fields = ("content_type_link",) diff --git a/src/openforms/config/migrations/0069_maptilelayer.py b/src/openforms/config/migrations/0069_maptilelayer.py new file mode 100644 index 0000000000..84b4ca94b7 --- /dev/null +++ b/src/openforms/config/migrations/0069_maptilelayer.py @@ -0,0 +1,56 @@ +# Generated by Django 4.2.17 on 2024-12-10 09:02 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("config", "0068_update_summary_tags"), + ] + + operations = [ + migrations.CreateModel( + name="MapTileLayer", + fields=[ + ( + "id", + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ( + "identifier", + models.SlugField( + help_text="A unique identifier for the tile layer", + unique=True, + verbose_name="identifier", + ), + ), + ( + "url", + models.URLField( + help_text="URL to the tile layer image. Used to define the map style/background the form map components. Example value: https://service.pdok.nl/brt/achtergrondkaart/wmts/v2_0/standaard/EPSG:28992/{z}/{x}/{y}.png", + max_length=255, + verbose_name="tile layer url", + ), + ), + ( + "label", + models.CharField( + help_text="An easily recognizable name for the tile layer, used to identify it.", + max_length=100, + verbose_name="label", + ), + ), + ], + options={ + "verbose_name": "map tile layer", + "verbose_name_plural": "map tile layers", + "ordering": ("label",), + }, + ), + ] diff --git a/src/openforms/config/models/__init__.py b/src/openforms/config/models/__init__.py index ae0efffa9d..9e082fe22c 100644 --- a/src/openforms/config/models/__init__.py +++ b/src/openforms/config/models/__init__.py @@ -1,11 +1,13 @@ from .color import RichTextColor from .config import GlobalConfiguration from .csp import CSPSetting +from .map import MapTileLayer from .theme import Theme __all__ = [ "CSPSetting", "GlobalConfiguration", "RichTextColor", + "MapTileLayer", "Theme", ] diff --git a/src/openforms/config/models/map.py b/src/openforms/config/models/map.py new file mode 100644 index 0000000000..67942f16a1 --- /dev/null +++ b/src/openforms/config/models/map.py @@ -0,0 +1,35 @@ +from django.db import models +from django.utils.translation import gettext_lazy as _ + + +class MapTileLayer(models.Model): + identifier = models.SlugField( + _("identifier"), + unique=True, + max_length=50, + help_text=_("A unique identifier for the tile layer"), + ) + url = models.URLField( + _("tile layer url"), + max_length=255, + help_text=_( + "URL to the tile layer image. " + "Used to define the map style/background the form map components. " + "Example value: https://service.pdok.nl/brt/achtergrondkaart/wmts/v2_0/standaard/EPSG:28992/{z}/{x}/{y}.png" + ), + ) + label = models.CharField( + _("label"), + max_length=100, + help_text=_( + "An easily recognizable name for the tile layer, used to identify it." + ), + ) + + class Meta: + verbose_name = _("map tile layer") + verbose_name_plural = _("map tile layers") + ordering = ("label",) + + def __str__(self): + return self.label diff --git a/src/openforms/fixtures/admin_index_unlisted.json b/src/openforms/fixtures/admin_index_unlisted.json index cf01210cff..2c93ee929d 100644 --- a/src/openforms/fixtures/admin_index_unlisted.json +++ b/src/openforms/fixtures/admin_index_unlisted.json @@ -1,5 +1,6 @@ [ "config.RichTextColor", + "config.MapTileLayer", "forms.FormLogic", "forms.FormDefinition", "forms.FormsExport",