Ticket #9278: geoadmin_rtl_fix_v2.diff

File geoadmin_rtl_fix_v2.diff, 4.6 KB (added by jbronn, 7 years ago)
  • django/contrib/gis/admin/options.py

     
    2828    scale_text = True
    2929    layerswitcher = True
    3030    scrollable = True
    31     admin_media_prefix = settings.ADMIN_MEDIA_PREFIX
    3231    map_width = 600
    3332    map_height = 400
    3433    map_srid = 4326
    3534    map_template = 'gis/admin/openlayers.html'
    36     openlayers_url = 'http://openlayers.org/api/2.6/OpenLayers.js'
     35    openlayers_url = 'http://openlayers.org/api/2.7/OpenLayers.js'
    3736    wms_url = 'http://labs.metacarta.com/wms/vmap0'
    3837    wms_layer = 'basic'
    3938    wms_name = 'OpenLayers WMS'
     
    7675        class OLMap(self.widget):
    7776            template = self.map_template
    7877            geom_type = db_field._geom
    79             params = {'admin_media_prefix' : self.admin_media_prefix,
    80                       'default_lon' : self.default_lon,
     78            params = {'default_lon' : self.default_lon,
    8179                      'default_lat' : self.default_lat,
    8280                      'default_zoom' : self.default_zoom,
    8381                      'display_wkt' : self.debug or self.display_wkt,
  • django/contrib/gis/admin/widgets.py

     
     1from django.conf import settings
    12from django.contrib.gis.gdal import OGRException
    23from django.contrib.gis.geos import GEOSGeometry, GEOSException
    34from django.forms.widgets import Textarea
    4 from django.template.loader import render_to_string
     5from django.template import loader, Context
     6from django.utils import translation
    57
     8# Creating a template context that will contain settings values needed
     9# by the OpenLayers templates.
     10geo_context = Context({'ADMIN_MEDIA_PREFIX' : settings.ADMIN_MEDIA_PREFIX,
     11                       'LANGUAGE_BIDI' : translation.get_language_bidi(),
     12                       })
     13
    614class OpenLayersWidget(Textarea):
    715    """
    816    Renders an OpenLayers map using the WKT of the geometry.
     
    4048            srid = self.params['srid']
    4149            if value.srid != srid:
    4250                try:
    43                     value.transform(srid)
    44                     wkt = value.wkt
     51                    ogr = value.ogr
     52                    ogr.transform(srid)
     53                    wkt = ogr.wkt
    4554                except OGRException:
    4655                    wkt = ''
    4756            else:
     
    5160            # geometry.
    5261            self.params['wkt'] = wkt
    5362
    54         return render_to_string(self.template, self.params)
     63        return loader.render_to_string(self.template, self.params,
     64                                       context_instance=geo_context)
    5565   
    5666    def map_options(self):
    5767        "Builds the map options hash for the OpenLayers template."
  • django/contrib/gis/templates/gis/admin/openlayers.html

     
    22<style type="text/css">
    33  #{{ id }}_map { width: {{ map_width }}px; height: {{ map_height }}px; }
    44  #{{ id }}_map .aligned label { float:inherit; }
    5   #{{ id }}_admin_map { position: relative; vertical-align: top; float: left; }
     5  #{{ id }}_admin_map { position: relative; vertical-align: top; float: {{ LANGUAGE_BIDI|yesno:"right,left" }}; }
    66  {% if not display_wkt %}#{{ id }} { display: none; }{% endif %}
    77  .olControlEditingToolbar .olControlModifyFeatureItemActive {
    8      background-image: url("{{ admin_media_prefix }}img/gis/move_vertex_on.png");
     8     background-image: url("{{ ADMIN_MEDIA_PREFIX }}img/gis/move_vertex_on.png");
    99     background-repeat: no-repeat;
    1010  }
    1111  .olControlEditingToolbar .olControlModifyFeatureItemInactive {
    12      background-image: url("{{ admin_media_prefix }}img/gis/move_vertex_off.png");
     12     background-image: url("{{ ADMIN_MEDIA_PREFIX }}img/gis/move_vertex_off.png");
    1313     background-repeat: no-repeat;
    1414  }
    1515</style>
     
    2929{% block openlayers %}{% include "gis/admin/openlayers.js" %}{% endblock %}
    3030//]]>
    3131</script>
    32 <div id="{{ id }}_map"></div>
     32<div id="{{ id }}_map"{% if LANGUAGE_BIDI %} dir="ltr"{% endif %}></div>
    3333<a href="javascript:{{ module }}.clearFeatures()">Delete all Features</a>
    3434{% if display_wkt %}<p> WKT debugging window:</p>{% endif %}
    3535<textarea id="{{ id }}" class="vWKTField required" cols="150" rows="10" name="{{ field_name }}">{{ wkt }}</textarea>
Back to Top