Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/openforms/config/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@
CSPSetting,
GlobalConfiguration,
MapTileLayer,
MapWFSTileLayer,
MapWMSTileLayer,
RichTextColor,
Theme,
)
from .resources import MapWMSTileLayerResource
from .resources import MapWFSTileLayerResource, MapWMSTileLayerResource


@admin.register(GlobalConfiguration)
Expand Down Expand Up @@ -264,6 +265,15 @@ class MapWMSTileLayerAdmin(ImportExportModelAdmin):
resource_classes = (MapWMSTileLayerResource,)


@admin.register(MapWFSTileLayer)
class MapWFSTileLayerAdmin(ImportExportModelAdmin):
list_display = ("name", "url", "uuid")
search_fields = ("name", "uuid")

# Import and export options:
resource_classes = (MapWFSTileLayerResource,)


@admin.register(CSPSetting)
class CSPSettingAdmin(admin.ModelAdmin):
readonly_fields = ("content_type_link",)
Expand Down
67 changes: 67 additions & 0 deletions src/openforms/config/migrations/0064_mapwfstilelayer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Generated by Django 4.2.24 on 2025-10-02 10:19

import uuid

from django.db import migrations, models


def add_default_wfs_tile_layers(apps, schema_editor):
from django.core.management import call_command

call_command("loaddata", "default_map_wfs_tile_layers")


class Migration(migrations.Migration):
dependencies = [
("config", "0063_alter_globalconfiguration_form_map_default_latitude_and_more"),
]

operations = [
migrations.CreateModel(
name="MapWFSTileLayer",
fields=[
(
"id",
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
(
"uuid",
models.UUIDField(
default=uuid.uuid4,
editable=False,
unique=True,
verbose_name="UUID",
),
),
(
"name",
models.CharField(
help_text="An easily recognizable name for the WFS tile layer, used to identify it.",
max_length=100,
verbose_name="name",
),
),
(
"url",
models.URLField(
help_text="URL to collect the WFS tile layer capabilities. To ensure correct functionality of the map, the WFS tile layer `getFeature` request should support EPSG 4326 projection and 'application/json' as output format.Example value: https://service.pdok.nl/lv/bag/wfs/v2_0?request=getCapabilities&service=WFS",
max_length=255,
verbose_name="tile layer url",
),
),
],
options={
"verbose_name": "WFS layer",
"verbose_name_plural": "WFS layers",
},
),
migrations.RunPython(
code=add_default_wfs_tile_layers,
reverse_code=migrations.RunPython.noop,
),
]
3 changes: 2 additions & 1 deletion src/openforms/config/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
from .color import RichTextColor
from .config import GlobalConfiguration
from .csp import CSPSetting
from .map import MapTileLayer, MapWMSTileLayer
from .map import MapTileLayer, MapWFSTileLayer, MapWMSTileLayer
from .theme import Theme

__all__ = [
"CSPSetting",
"GlobalConfiguration",
"RichTextColor",
"MapTileLayer",
"MapWFSTileLayer",
"MapWMSTileLayer",
"Theme",
]
43 changes: 43 additions & 0 deletions src/openforms/config/models/map.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,46 @@ def __str__(self):

def natural_key(self):
return (self.uuid,)


class MapWFSTileLayerManager(models.Manager["MapWFSTileLayer"]):
def get_by_natural_key(self, uuid: str) -> MapWFSTileLayer:
return self.get(uuid=uuid)


class MapWFSTileLayer(models.Model):
uuid = models.UUIDField(
_("UUID"),
unique=True,
default=_uuid.uuid4,
editable=False,
)
name = models.CharField(
_("name"),
max_length=100,
help_text=_(
"An easily recognizable name for the WFS tile layer, used to identify it."
),
)
url = models.URLField(
_("tile layer url"),
max_length=255,
help_text=_(
"URL to collect the WFS tile layer capabilities. To ensure correct "
"functionality of the map, the WFS tile layer `getFeature` request should "
"support EPSG 4326 projection and 'application/json' as output format."
"Example value: https://service.pdok.nl/lv/bag/wfs/v2_0?request=getCapabilities&service=WFS"
),
)

objects = MapWFSTileLayerManager()

class Meta:
verbose_name = _("WFS layer")
verbose_name_plural = _("WFS layers")

def __str__(self):
return self.name

def natural_key(self):
return (self.uuid,)
10 changes: 9 additions & 1 deletion src/openforms/config/resources.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from import_export import resources

from .models import MapWMSTileLayer
from .models import MapWFSTileLayer, MapWMSTileLayer


class MapWMSTileLayerResource(resources.ModelResource):
Expand All @@ -9,3 +9,11 @@ class Meta:
# Use uuid as identifier
import_id_fields = ("uuid",)
fields = ("uuid", "name", "url")


class MapWFSTileLayerResource(resources.ModelResource):
class Meta:
model = MapWFSTileLayer
# Use uuid as identifier
import_id_fields = ("uuid",)
fields = ("uuid", "name", "url")
8 changes: 8 additions & 0 deletions src/openforms/config/tests/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,11 @@ class MapWMSTileLayerFactory(factory.django.DjangoModelFactory):

class Meta:
model = "config.MapWMSTileLayer"


class MapWFSTileLayerFactory(factory.django.DjangoModelFactory):
url = factory.Sequence(lambda n: f"http://example-{n}.com")
name = factory.Faker("word")

class Meta:
model = "config.MapWFSTileLayer"
Loading
Loading