Fixed #11810 -- Fixed typo and errors that prevented `modifiable` from working in the geographic admin. Thanks to Rob Coup for the bug report. Refs #12504.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12995 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
2cd48bac7e
commit
1ad9c36fb8
|
@ -111,12 +111,6 @@ class GeoModelAdmin(ModelAdmin):
|
|||
}
|
||||
return OLMap
|
||||
|
||||
# Using the Beta OSM in the admin requires the following:
|
||||
# (1) The Google Maps Mercator projection needs to be added
|
||||
# to your `spatial_ref_sys` table. You'll need at least GDAL 1.5:
|
||||
# >>> from django.contrib.gis.gdal import SpatialReference
|
||||
# >>> from django.contrib.gis.utils import add_postgis_srs
|
||||
# >>> add_postgis_srs(SpatialReference(900913)) # Adding the Google Projection
|
||||
from django.contrib.gis import gdal
|
||||
if gdal.HAS_GDAL:
|
||||
class OSMGeoAdmin(GeoModelAdmin):
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
{# Author: Justin Bronn, Travis Pinney & Dane Springmeyer #}
|
||||
{% block vars %}var {{ module }} = {};
|
||||
{{ module }}.map = null; {{ module }}.controls = null; {{ module }}.panel = null; {{ module }}.re = new RegExp("^SRID=\d+;(.+)", "i"); {{ module }}.layers = {};
|
||||
{{ module }}.modifiable = {{ modifiable|yesno:"true,false" }};
|
||||
{{ module }}.wkt_f = new OpenLayers.Format.WKT();
|
||||
{{ module }}.is_collection = {{ is_collection|yesno:"true,false" }};
|
||||
{{ module }}.collection_type = '{{ collection_type }}';
|
||||
|
@ -88,12 +89,16 @@
|
|||
} else if ({{ module }}.is_point){
|
||||
draw_ctl = new OpenLayers.Control.DrawFeature(lyr, OpenLayers.Handler.Point, {'displayClass': 'olControlDrawFeaturePoint'});
|
||||
}
|
||||
{% if modifiable %}
|
||||
if ({{ module }}.modifiable){
|
||||
var mod = new OpenLayers.Control.ModifyFeature(lyr, {'displayClass': 'olControlModifyFeature'});
|
||||
{{ module }}.controls = [nav, draw_ctl, mod];
|
||||
{% else %}
|
||||
{{ module }}.controls = [nav, darw_ctl];
|
||||
{% endif %}
|
||||
} else {
|
||||
if(!lyr.features.length){
|
||||
{{ module }}.controls = [nav, draw_ctl];
|
||||
} else {
|
||||
{{ module }}.controls = [nav];
|
||||
}
|
||||
}
|
||||
}
|
||||
{{ module }}.init = function(){
|
||||
{% block map_options %}// The options hash, w/ zoom, resolution, and projection settings.
|
||||
|
@ -153,7 +158,9 @@
|
|||
{% if not scrollable %}{{ module }}.map.getControlsByClass('OpenLayers.Control.Navigation')[0].disableZoomWheel();{% endif %}
|
||||
{% endblock %}
|
||||
if (wkt){
|
||||
if ({{ module }}.modifiable){
|
||||
{{ module }}.enableEditing();
|
||||
}
|
||||
} else {
|
||||
{{ module }}.enableDrawing();
|
||||
}
|
||||
|
|
|
@ -47,11 +47,26 @@ GeoDjango's admin site
|
|||
Link to the URL of the OpenLayers JavaScript. Defaults to
|
||||
``'http://openlayers.org/api/2.8/OpenLayers.js'``.
|
||||
|
||||
|
||||
.. attribute:: modifiable
|
||||
|
||||
Defaults to ``False``. When set to to ``True``, disables editing of
|
||||
existing geometry fields in the admin.
|
||||
|
||||
.. note::
|
||||
|
||||
This is different from adding the geometry field to
|
||||
:attr:`~django.contrib.admin.ModelAdmin.readonly_fields`,
|
||||
which will only display the WKT of the geometry. Setting
|
||||
``modifiable=False``, actually displays the geometry in a map,
|
||||
but disables the ability to edit its vertices.
|
||||
|
||||
``OSMGeoAdmin``
|
||||
===============
|
||||
|
||||
.. class:: OSMGeoAdmin
|
||||
|
||||
A subclass of :class:`GeoModelAdmin` that uses a spherical mercator projection
|
||||
with OpenStreetMap street data tiles. See the :ref:`OSMGeoAdmin introduction <osmgeoadmin-intro>`
|
||||
with `OpenStreetMap <http://openstreetmap.org/>`_ street data tiles.
|
||||
See the :ref:`OSMGeoAdmin introduction <osmgeoadmin-intro>`
|
||||
in the tutorial for a usage example.
|
||||
|
|
Loading…
Reference in New Issue