Code

Ticket #16790: 16790.2.diff

File 16790.2.diff, 2.6 KB (added by jbronn, 3 years ago)

Added test stub.

Line 
1diff -r 382a03febff5 django/contrib/gis/admin/options.py
2--- a/django/contrib/gis/admin/options.py       Fri Sep 09 22:47:18 2011 +0000
3+++ b/django/contrib/gis/admin/options.py       Fri Sep 09 17:15:28 2011 -0700
4@@ -39,13 +39,13 @@
5     debug = False
6     widget = OpenLayersWidget
7 
8-    def _media(self):
9+    @property
10+    def media(self):
11         "Injects OpenLayers JavaScript into the admin."
12-        media = super(GeoModelAdmin, self)._media()
13+        media = super(GeoModelAdmin, self).media
14         media.add_js([self.openlayers_url])
15         media.add_js(self.extra_js)
16         return media
17-    media = property(_media)
18 
19     def formfield_for_dbfield(self, db_field, **kwargs):
20         """
21diff -r 382a03febff5 django/contrib/gis/tests/__init__.py
22--- a/django/contrib/gis/tests/__init__.py      Fri Sep 09 22:47:18 2011 +0000
23+++ b/django/contrib/gis/tests/__init__.py      Fri Sep 09 17:15:28 2011 -0700
24@@ -29,6 +29,9 @@
25 
26     # The following GeoDjango test apps depend on GDAL support.
27     if HAS_GDAL:
28+        # Geographic admin requires GDAL
29+        apps.append('geoadmin')
30+
31         # 3D apps use LayerMapping, which uses GDAL.
32         if connection.ops.postgis and GEOS_PREPARE:
33             apps.append('geo3d')
34diff -r 382a03febff5 django/contrib/gis/tests/geoadmin/models.py
35--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
36+++ b/django/contrib/gis/tests/geoadmin/models.py       Fri Sep 09 17:15:28 2011 -0700
37@@ -0,0 +1,10 @@
38+from django.contrib.gis.db import models
39+from django.contrib.gis import admin
40+
41+class City(models.Model):
42+    name = models.CharField(max_length=30)
43+    point = models.PointField()
44+    objects = models.GeoManager()
45+    def __unicode__(self): return self.name
46+
47+admin.site.register(City, admin.OSMGeoAdmin)
48diff -r 382a03febff5 django/contrib/gis/tests/geoadmin/tests.py
49--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
50+++ b/django/contrib/gis/tests/geoadmin/tests.py        Fri Sep 09 17:15:28 2011 -0700
51@@ -0,0 +1,10 @@
52+from django.test import TestCase
53+from django.contrib.gis import admin
54+from models import City
55+
56+class GeoAdminTest(TestCase):
57+    urls = 'django.contrib.gis.tests.geoadmin.urls'
58+
59+    def test01_ensure_geographic_media(self):
60+        geoadmin = admin.site._registry[City]
61+        # TODO: Ensure `geoadmin.media` has what we expect.
62diff -r 382a03febff5 django/contrib/gis/tests/geoadmin/urls.py
63--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
64+++ b/django/contrib/gis/tests/geoadmin/urls.py Fri Sep 09 17:15:28 2011 -0700
65@@ -0,0 +1,6 @@
66+from django.conf.urls.defaults import *
67+from django.contrib import admin
68+
69+urlpatterns = patterns('',
70+    (r'^admin/', include(admin.site.urls)),
71+)