Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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 authored September 10, 2011
6  django/contrib/gis/admin/options.py
@@ -39,13 +39,13 @@ class GeoModelAdmin(ModelAdmin):
39 39
     debug = False
40 40
     widget = OpenLayersWidget
41 41
 
42  
-    def _media(self):
  42
+    @property
  43
+    def media(self):
43 44
         "Injects OpenLayers JavaScript into the admin."
44  
-        media = super(GeoModelAdmin, self)._media()
  45
+        media = super(GeoModelAdmin, self).media
45 46
         media.add_js([self.openlayers_url])
46 47
         media.add_js(self.extra_js)
47 48
         return media
48  
-    media = property(_media)
49 49
 
50 50
     def formfield_for_dbfield(self, db_field, **kwargs):
51 51
         """
3  django/contrib/gis/tests/__init__.py
@@ -29,6 +29,9 @@ def geo_apps(namespace=True, runtests=False):
29 29
 
30 30
     # The following GeoDjango test apps depend on GDAL support.
31 31
     if HAS_GDAL:
  32
+        # Geographic admin requires GDAL
  33
+        apps.append('geoadmin')
  34
+
32 35
         # 3D apps use LayerMapping, which uses GDAL.
33 36
         if connection.ops.postgis and GEOS_PREPARE:
34 37
             apps.append('geo3d')
10  django/contrib/gis/tests/geoadmin/models.py
... ...
@@ -0,0 +1,10 @@
  1
+from django.contrib.gis.db import models
  2
+from django.contrib.gis import admin
  3
+
  4
+class City(models.Model):
  5
+    name = models.CharField(max_length=30)
  6
+    point = models.PointField()
  7
+    objects = models.GeoManager()
  8
+    def __unicode__(self): return self.name
  9
+
  10
+admin.site.register(City, admin.OSMGeoAdmin)
14  django/contrib/gis/tests/geoadmin/tests.py
... ...
@@ -0,0 +1,14 @@
  1
+from django.test import TestCase
  2
+from django.contrib.gis import admin
  3
+from models import City
  4
+
  5
+class GeoAdminTest(TestCase):
  6
+    urls = 'django.contrib.gis.tests.geoadmin.urls'
  7
+
  8
+    def test01_ensure_geographic_media(self):
  9
+        geoadmin = admin.site._registry[City]
  10
+        admin_js = geoadmin.media.render_js()
  11
+        osm_url = geoadmin.extra_js[0]
  12
+        self.assertTrue(any([geoadmin.openlayers_url in js for js in admin_js]))
  13
+        self.assertTrue(any([osm_url in js for js in admin_js]))
  14
+        
6  django/contrib/gis/tests/geoadmin/urls.py
... ...
@@ -0,0 +1,6 @@
  1
+from django.conf.urls.defaults import *
  2
+from django.contrib import admin
  3
+
  4
+urlpatterns = patterns('',
  5
+    (r'^admin/', include(admin.site.urls)),
  6
+)
0  gis/tests/geoadmin/__init__.py b/django/contrib/gis/tests/geoadmin/__init__.py
No changes.

0 notes on commit eaea9de

Please sign in to comment.
Something went wrong with that request. Please try again.