diff --git a/src/openforms/config/admin.py b/src/openforms/config/admin.py index 689b721757..4410921ee8 100644 --- a/src/openforms/config/admin.py +++ b/src/openforms/config/admin.py @@ -9,7 +9,13 @@ from .admin_views import ThemePreviewView from .forms import GlobalConfigurationAdminForm, ThemeAdminForm -from .models import CSPSetting, GlobalConfiguration, RichTextColor, Theme +from .models import ( + CSPSetting, + GlobalConfiguration, + RichTextColor, + LeafletMapBackground, + Theme, +) @admin.register(GlobalConfiguration) @@ -217,6 +223,20 @@ class RichTextColorAdmin(admin.ModelAdmin): ] +@admin.register(LeafletMapBackground) +class LeafletMapBackgroundAdmin(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/0067_leafletmapbackground.py b/src/openforms/config/migrations/0067_leafletmapbackground.py new file mode 100644 index 0000000000..3bce6d6c93 --- /dev/null +++ b/src/openforms/config/migrations/0067_leafletmapbackground.py @@ -0,0 +1,57 @@ +# Generated by Django 4.2.16 on 2024-11-21 14:14 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ( + "config", + "0066_alter_globalconfiguration_cosign_submission_confirmation_template_and_more", + ), + ] + + operations = [ + migrations.CreateModel( + name="LeafletMapBackground", + 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 Leaflet map background", + verbose_name="identifier", + ), + ), + ( + "url", + models.URLField( + help_text="URL to the Leaflet map background. Used for the form map components", + verbose_name="background url", + ), + ), + ( + "label", + models.CharField( + help_text="An easily recognizable name for the background, used to identify it.", + max_length=100, + verbose_name="label", + ), + ), + ], + options={ + "verbose_name": "leaflet map background option", + "verbose_name_plural": "leaflet map background options", + "ordering": ("label",), + }, + ), + ] diff --git a/src/openforms/config/models/__init__.py b/src/openforms/config/models/__init__.py index ae0efffa9d..8505785353 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 LeafletMapBackground from .theme import Theme __all__ = [ "CSPSetting", "GlobalConfiguration", "RichTextColor", + "LeafletMapBackground", "Theme", ] diff --git a/src/openforms/config/models/map.py b/src/openforms/config/models/map.py new file mode 100644 index 0000000000..3c57fc7faa --- /dev/null +++ b/src/openforms/config/models/map.py @@ -0,0 +1,30 @@ +from django.db import models +from django.utils.translation import gettext_lazy as _ + + +class LeafletMapBackground(models.Model): + identifier = models.SlugField( + _("identifier"), + help_text=_("A unique identifier for the Leaflet map background"), + ) + url = models.URLField( + _("background url"), + help_text=_( + "URL to the Leaflet map background. Used for the form map components" + ), + ) + label = models.CharField( + _("label"), + max_length=100, + help_text=_( + "An easily recognizable name for the background, used to identify it." + ), + ) + + class Meta: + verbose_name = _("leaflet map background option") + verbose_name_plural = _("leaflet map background options") + ordering = ("label",) + + def __str__(self): + return f"{self.label} ({self.url})" diff --git a/src/openforms/fixtures/admin_index_unlisted.json b/src/openforms/fixtures/admin_index_unlisted.json index cf01210cff..39b1d09b24 100644 --- a/src/openforms/fixtures/admin_index_unlisted.json +++ b/src/openforms/fixtures/admin_index_unlisted.json @@ -1,5 +1,6 @@ [ "config.RichTextColor", + "config.LeafletMapBackground", "forms.FormLogic", "forms.FormDefinition", "forms.FormsExport",