From b53ce2f31cd8241445a2cad81cd2ecdbdb54609c Mon Sep 17 00:00:00 2001 From: Claude Paroz Date: Tue, 3 Sep 2013 10:01:13 +0200 Subject: [PATCH] [1.6.x] Prevented rendering attrs to be squashed in OSMWidget Backport of b6889c68d7 from master. --- django/contrib/gis/forms/widgets.py | 9 +++++++-- django/contrib/gis/static/gis/js/OLMapWidget.js | 2 +- django/contrib/gis/tests/test_geoforms.py | 4 +++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/django/contrib/gis/forms/widgets.py b/django/contrib/gis/forms/widgets.py index 87e49d73c0..8b6cedf65c 100644 --- a/django/contrib/gis/forms/widgets.py +++ b/django/contrib/gis/forms/widgets.py @@ -111,5 +111,10 @@ class OSMWidget(BaseGeometryWidget): return 900913 def render(self, name, value, attrs=None): - return super(OSMWidget, self).render(name, value, - {'default_lon': self.default_lon, 'default_lat': self.default_lat}) + default_attrs = { + 'default_lon': self.default_lon, + 'default_lat': self.default_lat, + } + if attrs: + default_attrs.update(attrs) + return super(OSMWidget, self).render(name, value, default_attrs) diff --git a/django/contrib/gis/static/gis/js/OLMapWidget.js b/django/contrib/gis/static/gis/js/OLMapWidget.js index 252196b369..17da99be3d 100644 --- a/django/contrib/gis/static/gis/js/OLMapWidget.js +++ b/django/contrib/gis/static/gis/js/OLMapWidget.js @@ -213,7 +213,7 @@ function MapWidget(options) { var styleMap = new OpenLayers.StyleMap({'default': OpenLayers.Util.applyDefaults(defaults_style, OpenLayers.Feature.Vector.style['default'])}); this.layers.vector = new OpenLayers.Layer.Vector(" " + this.options.name, {styleMap: styleMap}); this.map.addLayer(this.layers.vector); - wkt = document.getElementById(this.options.id).value; + var wkt = document.getElementById(this.options.id).value; if (wkt) { var feat = OpenLayers.Util.properFeatures(this.read_wkt(wkt), this.options.geom_type); this.write_wkt(feat); diff --git a/django/contrib/gis/tests/test_geoforms.py b/django/contrib/gis/tests/test_geoforms.py index 1fd7f28106..64cecea7df 100644 --- a/django/contrib/gis/tests/test_geoforms.py +++ b/django/contrib/gis/tests/test_geoforms.py @@ -248,7 +248,9 @@ class SpecializedFieldTest(SimpleTestCase): geom = self.geometries['point'] form = PointForm(data={'p': geom}) - self.assertIn("OpenStreetMap (Mapnik)", form.as_p()) + rendered = form.as_p() + self.assertIn("OpenStreetMap (Mapnik)", rendered) + self.assertIn("id: 'id_p',", rendered) @skipUnless(HAS_GDAL and HAS_SPATIALREFSYS,