Ticket #19139: patch2.diff

File patch2.diff, 3.2 KB (added by Flavio Curella, 12 years ago)
  • django/contrib/gis/admin/widgets.py

    diff --git a/django/contrib/gis/admin/widgets.py b/django/contrib/gis/admin/widgets.py
    index 47570d3f9daedf741dd74838a959c4cb8d86893b..0102484f1900f509798e6d606ae86dd02290d657 100644
    a b class OpenLayersWidget(Textarea):  
    6464            # Setting the parameter WKT with that of the transformed
    6565            # geometry.
    6666            self.params['wkt'] = wkt
     67            self.params['value'] = value
    6768
    6869        return loader.render_to_string(self.template, self.params,
    6970                                       context_instance=geo_context)
  • django/contrib/gis/templates/gis/admin/openlayers.html

    diff --git a/django/contrib/gis/templates/gis/admin/openlayers.html b/django/contrib/gis/templates/gis/admin/openlayers.html
    index a61b68921f0182186274027d351e5c8af3213f4d..6dc244ae7ede6216b49bb231c61d35636b79792b 100644
    a b  
    3131//]]>
    3232</script>
    3333<div id="{{ id }}_map"{% if LANGUAGE_BIDI %} dir="ltr"{% endif %}></div>
     34{% if not value or modifiable %}
    3435<a href="javascript:{{ module }}.clearFeatures()">Delete all Features</a>
     36{% endif %}
    3537{% if display_wkt %}<p> WKT debugging window:</p>{% endif %}
    3638<textarea id="{{ id }}" class="vWKTField required" cols="150" rows="10" name="{{ name }}">{{ wkt }}</textarea>
    3739<script type="text/javascript">{% block init_function %}{{ module }}.init();{% endblock %}</script>
  • new file django/contrib/gis/tests/geoadmin/admin.py

    diff --git a/django/contrib/gis/tests/geoadmin/admin.py b/django/contrib/gis/tests/geoadmin/admin.py
    new file mode 100644
    index 0000000000000000000000000000000000000000..ab39c28885be89c9d8d6f07db6edf956facb2499
    - +  
     1from django.contrib.gis import admin
     2
     3
     4class UnmodifiableAdmin(admin.OSMGeoAdmin):
     5    modifiable = False
  • django/contrib/gis/tests/geoadmin/tests.py

    diff --git a/django/contrib/gis/tests/geoadmin/tests.py b/django/contrib/gis/tests/geoadmin/tests.py
    index 6fadebdb9a89bac3470bd3bbbac28c29ae8caad7..16302707e2d2388fb2a69a84e2f07c2b61137cab 100644
    a b from django.contrib.gis import admin  
    55from django.contrib.gis.geos import GEOSGeometry, Point
    66
    77from .models import City
     8from .admin import UnmodifiableAdmin
    89
    910
    1011class GeoAdminTest(TestCase):
    class GeoAdminTest(TestCase):  
    2324            """geodjango_point.layers.base = new OpenLayers.Layer.OSM("OpenStreetMap (Mapnik)");""",
    2425            result)
    2526
     27        self.assertIn(
     28            """<a href="javascript:geodjango_point.clearFeatures()">Delete all Features</a>""",
     29            result)
     30
     31        admin.site.unregister(City)
     32        admin.site.register(City, UnmodifiableAdmin)
     33        geoadmin = admin.site._registry[City]
     34        result = geoadmin.get_map_widget(City._meta.get_field('point'))(
     35            ).render('point', Point(-79.460734, 40.18476))
     36
     37        self.assertNotIn(
     38            """<a href="javascript:geodjango_point.clearFeatures()">Delete all Features</a>""",
     39            result)
     40
     41
    2642    def test_olmap_WMS_rendering(self):
    2743        admin.site.unregister(City)
    2844        admin.site.register(City, admin.GeoModelAdmin)
Back to Top