Skip to content

Commit

Permalink
✨ [#2173] Define map background url on request
Browse files Browse the repository at this point in the history
The map configuration can be edited at any moment. To make sure that we always return the correct map background url, we determined it per request.
  • Loading branch information
robinmolen committed Nov 25, 2024
1 parent 9f95e0e commit 7491954
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/openforms/formio/components/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from rest_framework.request import Request

from openforms.authentication.service import AuthAttribute
from openforms.config.models import GlobalConfiguration
from openforms.config.models import GlobalConfiguration, LeafletMapBackground
from openforms.submissions.models import Submission
from openforms.typing import DataMapping
from openforms.utils.date import TIMEZONE_AMS, datetime_in_amsterdam, format_date_value
Expand Down Expand Up @@ -198,6 +198,15 @@ def rewrite_for_request(component, request: Request):
component["initialCenter"]["lat"] = config.form_map_default_latitude
component["initialCenter"]["lng"] = config.form_map_default_longitude

try:
leaflet_map_background = LeafletMapBackground.objects.get(
identifier=component["backgroundIdentifier"]
)
# Write the background url information
component["url"] = leaflet_map_background.url
except LeafletMapBackground.DoesNotExist:
return None

def build_serializer_field(self, component: Component) -> serializers.ListField:
validate = component.get("validate", {})
required = validate.get("required", False)
Expand Down

0 comments on commit 7491954

Please sign in to comment.