Fixed #16790 -- Modified the geographic admin to work after r16594. Thanks, jdiego, for the bug report and patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@16775 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Justin Bronn 2011-09-10 03:04:30 +00:00
parent 5fbf5fd3dd
commit eaea9deca8
6 changed files with 36 additions and 3 deletions

View File

@ -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):
"""

View File

@ -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')

View File

@ -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)

View File

@ -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]))

View File

@ -0,0 +1,6 @@
from django.conf.urls.defaults import *
from django.contrib import admin
urlpatterns = patterns('',
(r'^admin/', include(admin.site.urls)),
)