Skip to content
Merged
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
5 changes: 4 additions & 1 deletion CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@
CHANGELOG
=========

0.32.1 (unreleased)
0.33.0 (unreleased)
-------------------

- CSP: Don't test nonce for truthiness before inclusion #393
- Solve broken marker image paths in the admin panel #392
- `map_width` and `map_height` are no longer supported in LeafletWidget `attrs`,
use traditional CSS to dimension maps (you can target the class
`.leaflet-container-default` for example.)

0.32.0 (2025-05-14)
-------------------
Expand Down
2 changes: 0 additions & 2 deletions docs/widget.rst
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,6 @@ To show a textarea input for the raw GeoJSON geometry, override admin ``form_fie
from django.contrib.gis.db import models as geo_models

LEAFLET_WIDGET_ATTRS = {
'map_height': '500px',
'map_width': '100%',
'display_raw': 'true',
'map_srid': 4326,
}
Expand Down
9 changes: 1 addition & 8 deletions leaflet/templates/leaflet/widget.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,6 @@
{{ FORCE_IMAGE_PATH|json_script:"force-img-path" }}
{{ reset_view_icon|json_script:"Control-ResetView-ICON" }}

<style nonce="{{ csp_nonce }}">
{% block map_css %}
{% if map_width and map_height %}#{{ id_map }} { width: {{ map_width|unlocalize }}; height: {{ map_height|unlocalize }}; }{% endif %}
{% if not display_raw %}#{{ id_css }} { display: none; }{% endif %}
{% endblock map_css %}
</style>

<script nonce="{{ csp_nonce }}">
{% block vars %}var {{ module }} = {};
{{ module }}.fieldid = '{{ id_css }}';
Expand Down Expand Up @@ -53,4 +46,4 @@
target="_blank"
rel="nofollow">valid GeoJSON Geometry</a>:</p>
{% endif %}
<textarea id="{{ id_css }}" class="required django-leaflet-raw-textarea {{ class }}" cols="150" rows="10" name="{{ name }}">{{ serialized }}</textarea>
<textarea id="{{ id_css }}" class="required django-leaflet-raw-textarea {{ class }}" cols="150" rows="10" name="{{ name }}"{% if not display_raw %} hidden{% endif %}>{{ serialized }}</textarea>
4 changes: 2 additions & 2 deletions leaflet/tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ def test_default_parameters(self):
self.assertIn(".fieldid = 'geom'", output)
self.assertIn(".srid = 4326", output)
self.assertIn(".geom_type = 'Geometry'", output)
self.assertIn('#geom { display: none; }', output)
self.assertIn('name="geom" hidden', output)
self.assertIn('function geom_map_callback(map, options)', output)

def test_overriden_parameters(self):
Expand All @@ -237,7 +237,7 @@ class PolygonWidget(LeafletWidget):
output = widget.render('geometry', '', {'id': 'geometry'})
self.assertIn(".fieldid = 'geometry'", output)
self.assertIn(".geom_type = 'Polygon'", output)
self.assertIn('#geometry { display: none; }', output)
self.assertIn('name="geometry" hidden', output)
self.assertIn('function geometry_map_callback(map, options)', output)

def test_javascript_safe_callback_name(self):
Expand Down