diff --git a/django/contrib/gis/admin/options.py b/django/contrib/gis/admin/options.py index 71fb87bf09..26d60e55c8 100644 --- a/django/contrib/gis/admin/options.py +++ b/django/contrib/gis/admin/options.py @@ -28,12 +28,11 @@ class GeoModelAdmin(ModelAdmin): scale_text = True layerswitcher = True scrollable = True - admin_media_prefix = settings.ADMIN_MEDIA_PREFIX map_width = 600 map_height = 400 map_srid = 4326 map_template = 'gis/admin/openlayers.html' - openlayers_url = 'http://openlayers.org/api/2.6/OpenLayers.js' + openlayers_url = 'http://openlayers.org/api/2.7/OpenLayers.js' wms_url = 'http://labs.metacarta.com/wms/vmap0' wms_layer = 'basic' wms_name = 'OpenLayers WMS' @@ -76,8 +75,7 @@ class GeoModelAdmin(ModelAdmin): class OLMap(self.widget): template = self.map_template geom_type = db_field._geom - params = {'admin_media_prefix' : self.admin_media_prefix, - 'default_lon' : self.default_lon, + params = {'default_lon' : self.default_lon, 'default_lat' : self.default_lat, 'default_zoom' : self.default_zoom, 'display_wkt' : self.debug or self.display_wkt, diff --git a/django/contrib/gis/admin/widgets.py b/django/contrib/gis/admin/widgets.py index 27abc8f59b..02e1764630 100644 --- a/django/contrib/gis/admin/widgets.py +++ b/django/contrib/gis/admin/widgets.py @@ -1,7 +1,15 @@ +from django.conf import settings from django.contrib.gis.gdal import OGRException from django.contrib.gis.geos import GEOSGeometry, GEOSException from django.forms.widgets import Textarea -from django.template.loader import render_to_string +from django.template import loader, Context +from django.utils import translation + +# Creating a template context that contains Django settings +# values needed by admin map templates. +geo_context = Context({'ADMIN_MEDIA_PREFIX' : settings.ADMIN_MEDIA_PREFIX, + 'LANGUAGE_BIDI' : translation.get_language_bidi(), + }) class OpenLayersWidget(Textarea): """ @@ -40,8 +48,9 @@ class OpenLayersWidget(Textarea): srid = self.params['srid'] if value.srid != srid: try: - value.transform(srid) - wkt = value.wkt + ogr = value.ogr + ogr.transform(srid) + wkt = ogr.wkt except OGRException: wkt = '' else: @@ -51,7 +60,8 @@ class OpenLayersWidget(Textarea): # geometry. self.params['wkt'] = wkt - return render_to_string(self.template, self.params) + return loader.render_to_string(self.template, self.params, + context_instance=geo_context) def map_options(self): "Builds the map options hash for the OpenLayers template." diff --git a/django/contrib/gis/templates/gis/admin/openlayers.html b/django/contrib/gis/templates/gis/admin/openlayers.html index acf82b284e..361cac55b4 100644 --- a/django/contrib/gis/templates/gis/admin/openlayers.html +++ b/django/contrib/gis/templates/gis/admin/openlayers.html @@ -2,14 +2,14 @@ @@ -29,7 +29,7 @@ {% block openlayers %}{% include "gis/admin/openlayers.js" %}{% endblock %} //]]> -
+ Delete all Features {% if display_wkt %}WKT debugging window:
{% endif %}