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):
|
77 | 77 | # Setting the parameter WKT with that of the transformed |
78 | 78 | # geometry. |
79 | 79 | self.params['wkt'] = wkt |
| 80 | self.params['editable'] = self.params['modifiable'] |
| 81 | else: |
| 82 | self.params['editable'] = True |
80 | 83 | |
81 | 84 | return loader.render_to_string(self.template, self.params, |
82 | 85 | context_instance=geo_context) |
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
|
|
31 | 31 | //]]> |
32 | 32 | </script> |
33 | 33 | <div id="{{ id }}_map"{% if LANGUAGE_BIDI %} dir="ltr"{% endif %}></div> |
| 34 | {% if editable %} |
34 | 35 | <a href="javascript:{{ module }}.clearFeatures()">Delete all Features</a> |
| 36 | {% endif %} |
35 | 37 | {% if display_wkt %}<p> WKT debugging window:</p>{% endif %} |
36 | 38 | <textarea id="{{ id }}" class="vWKTField required" cols="150" rows="10" name="{{ name }}">{{ wkt }}</textarea> |
37 | 39 | <script type="text/javascript">{% block init_function %}{{ module }}.init();{% endblock %}</script> |
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
-
|
+
|
|
| 1 | from django.contrib.gis import admin |
| 2 | |
| 3 | |
| 4 | class UnmodifiableAdmin(admin.OSMGeoAdmin): |
| 5 | modifiable = False |
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
|
5 | 5 | from django.contrib.gis.geos import GEOSGeometry, Point |
6 | 6 | |
7 | 7 | from .models import City |
| 8 | from .admin import UnmodifiableAdmin |
8 | 9 | |
9 | 10 | |
10 | 11 | class GeoAdminTest(TestCase): |
… |
… |
class GeoAdminTest(TestCase):
|
23 | 24 | """geodjango_point.layers.base = new OpenLayers.Layer.OSM("OpenStreetMap (Mapnik)");""", |
24 | 25 | result) |
25 | 26 | |
| 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 | |
26 | 42 | def test_olmap_WMS_rendering(self): |
27 | 43 | admin.site.unregister(City) |
28 | 44 | admin.site.register(City, admin.GeoModelAdmin) |