From b6889c68d7af2e3b8efa01f7050c068afe015080 Mon Sep 17 00:00:00 2001 From: Claude Paroz Date: Tue, 3 Sep 2013 10:01:13 +0200 Subject: [PATCH] Prevented rendering attrs to be squashed in OSMWidget --- 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 d55c5c87e9..8fc7263dbf 100644 --- a/django/contrib/gis/tests/test_geoforms.py +++ b/django/contrib/gis/tests/test_geoforms.py @@ -250,7 +250,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,