Commit eaea9dec authored by Justin Bronn's avatar Justin Bronn
Browse files

Fixed #16790 -- Modified the geographic admin to work after r16594. Thanks,...

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
parent 5fbf5fd3
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -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 −0
Original line number Diff line number Diff line
@@ -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 −0

Empty file added.

+10 −0
Original line number Diff line number Diff line
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 −0
Original line number Diff line number Diff line
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]))
        
Loading