Ticket #19139: patch3.diff

File patch3.diff, 3.3 KB (added by fcurella, 2 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 ceb8e9c9bd9c9cc6e7c43740657b9d767b3984c3..dd019a9cbe0112d2e69825f2c77b7472568e90c9 100644
    a b class OpenLayersWidget(Textarea): 
    7777            # Setting the parameter WKT with that of the transformed
    7878            # geometry.
    7979            self.params['wkt'] = wkt
     80            self.params['editable'] = self.params['modifiable']
     81        else:
     82            self.params['editable'] = True
    8083
    8184        return loader.render_to_string(self.template, self.params,
    8285                                       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..23693eb10f853ac298048812f3244a4eb423d300 100644
    a b  
    3131//]]>
    3232</script>
    3333<div id="{{ id }}_map"{% if LANGUAGE_BIDI %} dir="ltr"{% endif %}></div>
     34{% if editable %}
    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 669914bdea67a628ff177f350d271e27abc41acd..808729ccaccb32bc11b173b14f4d019c766a0050 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