Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #16790 -- Modified the geographic admin to work after r16594. T…

…hanks, jdiego, for the bug report and patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@16775 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit eaea9deca849262a677fec0f0d74495bb146f691 1 parent 5fbf5fd
Justin Bronn jbronn authored
6 django/contrib/gis/admin/options.py
View
@@ -39,13 +39,13 @@ class GeoModelAdmin(ModelAdmin):
debug = False
widget = OpenLayersWidget
- def _media(self):
+ @property
+ def media(self):
"Injects OpenLayers JavaScript into the admin."
- media = super(GeoModelAdmin, self)._media()
+ media = super(GeoModelAdmin, self).media
media.add_js([self.openlayers_url])
media.add_js(self.extra_js)
return media
- media = property(_media)
def formfield_for_dbfield(self, db_field, **kwargs):
"""
3  django/contrib/gis/tests/__init__.py
View
@@ -29,6 +29,9 @@ def geo_apps(namespace=True, runtests=False):
# The following GeoDjango test apps depend on GDAL support.
if HAS_GDAL:
+ # Geographic admin requires GDAL
+ apps.append('geoadmin')
+
# 3D apps use LayerMapping, which uses GDAL.
if connection.ops.postgis and GEOS_PREPARE:
apps.append('geo3d')
0  django/contrib/gis/tests/geoadmin/__init__.py
View
No changes.
10 django/contrib/gis/tests/geoadmin/models.py
View
@@ -0,0 +1,10 @@
+from django.contrib.gis.db import models
+from django.contrib.gis import admin
+
+class City(models.Model):
+ name = models.CharField(max_length=30)
+ point = models.PointField()
+ objects = models.GeoManager()
+ def __unicode__(self): return self.name
+
+admin.site.register(City, admin.OSMGeoAdmin)
14 django/contrib/gis/tests/geoadmin/tests.py
View
@@ -0,0 +1,14 @@
+from django.test import TestCase
+from django.contrib.gis import admin
+from models import City
+
+class GeoAdminTest(TestCase):
+ urls = 'django.contrib.gis.tests.geoadmin.urls'
+
+ def test01_ensure_geographic_media(self):
+ geoadmin = admin.site._registry[City]
+ admin_js = geoadmin.media.render_js()
+ osm_url = geoadmin.extra_js[0]
+ self.assertTrue(any([geoadmin.openlayers_url in js for js in admin_js]))
+ self.assertTrue(any([osm_url in js for js in admin_js]))
+
6 django/contrib/gis/tests/geoadmin/urls.py
View
@@ -0,0 +1,6 @@
+from django.conf.urls.defaults import *
+from django.contrib import admin
+
+urlpatterns = patterns('',
+ (r'^admin/', include(admin.site.urls)),
+)
Please sign in to comment.
Something went wrong with that request. Please try again.