Refs #27674 --- Deprecated django.contrib.gis.admin.OpenLayersWidget.

This commit is contained in:
Mariusz Felisiak 2022-04-22 11:36:27 +02:00 committed by GitHub
parent 6f453cd298
commit eeb0bb6379
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 21 additions and 1 deletions

View File

@ -27,8 +27,8 @@ __all__ = [
"register", "register",
"site", "site",
"GISModelAdmin", "GISModelAdmin",
"OpenLayersWidget",
# RemovedInDjango50Warning. # RemovedInDjango50Warning.
"GeoModelAdmin", "GeoModelAdmin",
"OpenLayersWidget",
"OSMGeoAdmin", "OSMGeoAdmin",
] ]

View File

@ -1,9 +1,12 @@
# RemovedInDjango50Warning.
import logging import logging
import warnings
from django.contrib.gis.gdal import GDALException from django.contrib.gis.gdal import GDALException
from django.contrib.gis.geos import GEOSException, GEOSGeometry from django.contrib.gis.geos import GEOSException, GEOSGeometry
from django.forms.widgets import Textarea from django.forms.widgets import Textarea
from django.utils import translation from django.utils import translation
from django.utils.deprecation import RemovedInDjango50Warning
# Creating a template context that contains Django settings # Creating a template context that contains Django settings
# values needed by admin map templates. # values needed by admin map templates.
@ -16,6 +19,14 @@ class OpenLayersWidget(Textarea):
Render an OpenLayers map using the WKT of the geometry. Render an OpenLayers map using the WKT of the geometry.
""" """
def __init__(self, *args, **kwargs):
warnings.warn(
"django.contrib.gis.admin.OpenLayersWidget is deprecated.",
RemovedInDjango50Warning,
stacklevel=2,
)
super().__init__(*args, **kwargs)
def get_context(self, name, value, attrs): def get_context(self, name, value, attrs):
# Update the template parameters with any attributes passed in. # Update the template parameters with any attributes passed in.
if attrs: if attrs:

View File

@ -101,6 +101,8 @@ details on these changes.
``SimpleTestCase.assertFormError()`` and ``assertFormsetError()`` will no ``SimpleTestCase.assertFormError()`` and ``assertFormsetError()`` will no
longer be allowed. longer be allowed.
* The ``django.contrib.gis.admin.OpenLayersWidget`` will be removed.
.. _deprecation-removed-in-4.1: .. _deprecation-removed-in-4.1:
4.1 4.1

View File

@ -610,6 +610,8 @@ Miscellaneous
or pass the form/formset object directly instead. or pass the form/formset object directly instead.
* The undocumented ``django.contrib.gis.admin.OpenLayersWidget`` is deprecated.
Features removed in 4.1 Features removed in 4.1
======================= =======================

View File

@ -125,3 +125,8 @@ class DeprecationTests(SimpleTestCase):
DeprecatedOSMGeoAdmin(City, site) DeprecatedOSMGeoAdmin(City, site)
with self.assertRaisesMessage(RemovedInDjango50Warning, msg): with self.assertRaisesMessage(RemovedInDjango50Warning, msg):
DeprecatedGeoModelAdmin(City, site) DeprecatedGeoModelAdmin(City, site)
def test_openlayerswidget_warning(self):
msg = "django.contrib.gis.admin.OpenLayersWidget is deprecated."
with self.assertRaisesMessage(RemovedInDjango50Warning, msg):
admin.OpenLayersWidget()