fix: Handle missing locations

This commit is contained in:
moanos [he/him] 2024-09-27 19:48:05 +02:00
parent a1edb48ff5
commit 803a6ff000
2 changed files with 6 additions and 1 deletions

View File

@ -19,6 +19,7 @@
}).addControl(new maplibregl.NavigationControl()); }).addControl(new maplibregl.NavigationControl());
{% for adoption_notice in adoption_notices %} {% for adoption_notice in adoption_notices %}
{% if adoption_notice.location %}
// create the popup // create the popup
const popup_{{ forloop.counter }} = new maplibregl.Popup({offset: 25}).setHTML(`{% include "fellchensammlung/partials/partial-adoption-notice-minimal.html" %}`); const popup_{{ forloop.counter }} = new maplibregl.Popup({offset: 25}).setHTML(`{% include "fellchensammlung/partials/partial-adoption-notice-minimal.html" %}`);
@ -33,5 +34,6 @@
.setLngLat(location_popup_{{ forloop.counter }}) .setLngLat(location_popup_{{ forloop.counter }})
.setPopup(popup_{{ forloop.counter }}) // sets a popup on this marker .setPopup(popup_{{ forloop.counter }}) // sets a popup on this marker
.addTo(map); .addTo(map);
{% endif %}
{% endfor %} {% endfor %}
</script> </script>

View File

@ -51,4 +51,7 @@ def get_oxitraffic_script_if_enabled():
@register.filter @register.filter
@stringfilter @stringfilter
def pointdecimal(value): def pointdecimal(value):
try:
return f"{float(value):.9f}" return f"{float(value):.9f}"
except ValueError:
return value