Skip to content

Commit

Permalink
✨ [#2173] Add leaflet map admin configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
robinmolen committed Nov 21, 2024
1 parent e4fb7bb commit 0fd08bf
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/openforms/config/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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",)
Expand Down
57 changes: 57 additions & 0 deletions src/openforms/config/migrations/0067_leafletmapbackground.py
Original file line number Diff line number Diff line change
@@ -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",),
},
),
]
2 changes: 2 additions & 0 deletions src/openforms/config/models/__init__.py
Original file line number Diff line number Diff line change
@@ -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",
]
30 changes: 30 additions & 0 deletions src/openforms/config/models/map.py
Original file line number Diff line number Diff line change
@@ -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})"
1 change: 1 addition & 0 deletions src/openforms/fixtures/admin_index_unlisted.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[
"config.RichTextColor",
"config.LeafletMapBackground",
"forms.FormLogic",
"forms.FormDefinition",
"forms.FormsExport",
Expand Down

0 comments on commit 0fd08bf

Please sign in to comment.