Skip to content

Commit

Permalink
[1.5.x] Fixed #20773 -- [gis] Fixed regression in GoogleMap output
Browse files Browse the repository at this point in the history
Thanks Martyn Clement for the report and the initial patch.
Backport of 27c1a72 from master.
  • Loading branch information
claudep committed Jul 22, 2013
1 parent 9386bbc commit 0191011
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
3 changes: 2 additions & 1 deletion django/contrib/gis/maps/google/gmap.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ def js(self):
@property @property
def scripts(self): def scripts(self):
"Returns all <script></script> tags required with Google Maps JavaScript." "Returns all <script></script> tags required with Google Maps JavaScript."
return format_html('%s\n <script type="text/javascript">\n//<![CDATA[\n%s//]]>\n </script>', self.api_script, mark_safe(self.js)) return format_html('{0}\n <script type="text/javascript">\n//<![CDATA[\n{1}//]]>\n </script>',
self.api_script, mark_safe(self.js))


@property @property
def style(self): def style(self):
Expand Down
21 changes: 19 additions & 2 deletions django/contrib/gis/tests/geoadmin/tests.py
Original file line number Original file line Diff line number Diff line change
@@ -1,11 +1,14 @@
from __future__ import absolute_import from __future__ import absolute_import


from django.test import TestCase
from django.contrib.gis import admin from django.contrib.gis import admin
from django.contrib.gis.geos import GEOSGeometry, Point from django.contrib.gis.geos import GEOSGeometry, Point
from django.test import TestCase
from django.test.utils import override_settings


from .models import City from .models import City


GOOGLE_MAPS_API_KEY = 'XXXX'



class GeoAdminTest(TestCase): class GeoAdminTest(TestCase):
urls = 'django.contrib.gis.tests.geoadmin.urls' urls = 'django.contrib.gis.tests.geoadmin.urls'
Expand Down Expand Up @@ -35,7 +38,9 @@ def test_olmap_WMS_rendering(self):
result) result)


def test_olwidget_has_changed(self): def test_olwidget_has_changed(self):
""" Check that changes are accurately noticed by OpenLayersWidget. """ """
Check that changes are accurately noticed by OpenLayersWidget.
"""
geoadmin = admin.site._registry[City] geoadmin = admin.site._registry[City]
form = geoadmin.get_changelist_form(None)() form = geoadmin.get_changelist_form(None)()
has_changed = form.fields['point'].widget._has_changed has_changed = form.fields['point'].widget._has_changed
Expand All @@ -51,3 +56,15 @@ def test_olwidget_has_changed(self):
self.assertFalse(has_changed(initial, data_same)) self.assertFalse(has_changed(initial, data_same))
self.assertFalse(has_changed(initial, data_almost_same)) self.assertFalse(has_changed(initial, data_almost_same))
self.assertTrue(has_changed(initial, data_changed)) self.assertTrue(has_changed(initial, data_changed))

@override_settings(GOOGLE_MAPS_API_KEY=GOOGLE_MAPS_API_KEY)
def test_google_map_scripts(self):
"""
Testing GoogleMap.scripts() output. See #20773.
"""
from django.contrib.gis.maps.google.gmap import GoogleMap

google_map = GoogleMap()
scripts = google_map.scripts
self.assertIn(GOOGLE_MAPS_API_KEY, scripts)
self.assertIn("new GMap2", scripts)

0 comments on commit 0191011

Please sign in to comment.