diff options
| -rw-r--r-- | django/contrib/gis/forms/widgets.py | 17 | ||||
| -rw-r--r-- | django/contrib/gis/static/gis/js/OLMapWidget.js | 5 | ||||
| -rw-r--r-- | django/contrib/gis/templates/gis/openlayers.html | 3 | ||||
| -rw-r--r-- | docs/ref/contrib/gis/forms-api.txt | 10 | ||||
| -rw-r--r-- | docs/releases/5.1.txt | 3 | ||||
| -rw-r--r-- | tests/gis_tests/test_geoforms.py | 19 |
6 files changed, 5 insertions, 52 deletions
diff --git a/django/contrib/gis/forms/widgets.py b/django/contrib/gis/forms/widgets.py index 49ca48794b..55895ae9f3 100644 --- a/django/contrib/gis/forms/widgets.py +++ b/django/contrib/gis/forms/widgets.py @@ -1,5 +1,4 @@ import logging -import warnings from django.conf import settings from django.contrib.gis import gdal @@ -7,7 +6,6 @@ from django.contrib.gis.geometry import json_regex from django.contrib.gis.geos import GEOSException, GEOSGeometry from django.forms.widgets import Widget from django.utils import translation -from django.utils.deprecation import RemovedInDjango51Warning logger = logging.getLogger("django.contrib.gis") @@ -20,8 +18,6 @@ class BaseGeometryWidget(Widget): geom_type = "GEOMETRY" map_srid = 4326 - map_width = 600 # RemovedInDjango51Warning - map_height = 400 # RemovedInDjango51Warning display_raw = False supports_3d = False @@ -29,19 +25,8 @@ class BaseGeometryWidget(Widget): def __init__(self, attrs=None): self.attrs = {} - for key in ("geom_type", "map_srid", "map_width", "map_height", "display_raw"): + for key in ("geom_type", "map_srid", "display_raw"): self.attrs[key] = getattr(self, key) - if ( - (attrs and ("map_width" in attrs or "map_height" in attrs)) - or self.map_width != 600 - or self.map_height != 400 - ): - warnings.warn( - "The map_height and map_width widget attributes are deprecated. Please " - "use CSS to size map widgets.", - category=RemovedInDjango51Warning, - stacklevel=2, - ) if attrs: self.attrs.update(attrs) diff --git a/django/contrib/gis/static/gis/js/OLMapWidget.js b/django/contrib/gis/static/gis/js/OLMapWidget.js index b750327409..f3025f24ac 100644 --- a/django/contrib/gis/static/gis/js/OLMapWidget.js +++ b/django/contrib/gis/static/gis/js/OLMapWidget.js @@ -62,11 +62,6 @@ class MapWidget { this.options.base_layer = new ol.layer.Tile({source: new ol.source.OSM()}); } - // RemovedInDjango51Warning: when the deprecation ends, remove setting - // width/height (3 lines below). - const mapContainer = document.getElementById(this.options.map_id); - mapContainer.style.width = `${mapContainer.dataset.width}px`; - mapContainer.style.height = `${mapContainer.dataset.height}px`; this.map = this.createMap(); this.featureCollection = new ol.Collection(); this.featureOverlay = new ol.layer.Vector({ diff --git a/django/contrib/gis/templates/gis/openlayers.html b/django/contrib/gis/templates/gis/openlayers.html index 2849813c6e..f9f7e5fa51 100644 --- a/django/contrib/gis/templates/gis/openlayers.html +++ b/django/contrib/gis/templates/gis/openlayers.html @@ -1,8 +1,7 @@ {% load i18n l10n %} <div id="{{ id }}_div_map" class="dj_map_wrapper"> - {# RemovedInDjango51Warning: when the deprecation ends, remove data-width and data-height attributes. #} - <div id="{{ id }}_map" class="dj_map" data-width="{{ map_width }}" data-height="{{ map_height }}"></div> + <div id="{{ id }}_map" class="dj_map"></div> {% if not disabled %}<span class="clear_features"><a href="">{% translate "Delete all Features" %}</a></span>{% endif %} {% if display_raw %}<p>{% translate "Debugging window (serialized value)" %}</p>{% endif %} <textarea id="{{ id }}" class="vSerializedField required" cols="150" rows="10" name="{{ name }}" diff --git a/docs/ref/contrib/gis/forms-api.txt b/docs/ref/contrib/gis/forms-api.txt index 11e1bc77f4..61308c5933 100644 --- a/docs/ref/contrib/gis/forms-api.txt +++ b/docs/ref/contrib/gis/forms-api.txt @@ -101,16 +101,6 @@ from other Django widget attributes. The OpenGIS geometry type, generally set by the form field. -.. attribute:: BaseGeometryWidget.map_height -.. attribute:: BaseGeometryWidget.map_width - - Height and width of the widget map (default is 400x600). - - .. deprecated:: 4.2 - - ``map_height`` and ``map_width`` attributes are deprecated, use CSS to - size map widgets instead. - .. attribute:: BaseGeometryWidget.map_srid SRID code used by the map (default is 4326). diff --git a/docs/releases/5.1.txt b/docs/releases/5.1.txt index d4510d30db..a1825a7954 100644 --- a/docs/releases/5.1.txt +++ b/docs/releases/5.1.txt @@ -267,3 +267,6 @@ to remove usage of these features. support in historical migrations. * The ``django.contrib.postgres.fields.CIText`` mixin is removed. + +* The ``map_width`` and ``map_height`` attributes of ``BaseGeometryWidget`` are + removed. diff --git a/tests/gis_tests/test_geoforms.py b/tests/gis_tests/test_geoforms.py index b8105645bf..c351edaaad 100644 --- a/tests/gis_tests/test_geoforms.py +++ b/tests/gis_tests/test_geoforms.py @@ -5,7 +5,6 @@ from django.contrib.gis.forms import BaseGeometryWidget, OpenLayersWidget from django.contrib.gis.geos import GEOSGeometry from django.core.exceptions import ValidationError from django.test import SimpleTestCase, override_settings -from django.utils.deprecation import RemovedInDjango51Warning from django.utils.html import escape @@ -445,9 +444,7 @@ class GeometryWidgetTests(SimpleTestCase): "is_hidden": False, "attrs": { "map_srid": 4326, - "map_width": 600, "geom_type": "GEOMETRY", - "map_height": 400, "display_raw": False, }, "name": "name", @@ -486,19 +483,3 @@ class GeometryWidgetTests(SimpleTestCase): form = PointForm(data={"p": point.json}) self.assertTrue(form.is_valid()) self.assertEqual(form.cleaned_data["p"].srid, 4326) - - def test_deprecated_width_and_height(self): - class CustomGeometryWidget(forms.BaseGeometryWidget): - map_height = 300 - map_width = 550 - - msg = ( - "The map_height and map_width widget attributes are deprecated. Please use " - "CSS to size map widgets." - ) - with self.assertRaisesMessage(RemovedInDjango51Warning, msg): - CustomGeometryWidget() - with self.assertRaisesMessage(RemovedInDjango51Warning, msg): - forms.BaseGeometryWidget({"map_width": 400}) - with self.assertRaisesMessage(RemovedInDjango51Warning, msg): - forms.BaseGeometryWidget({"map_height": 600}) |
