Loading django/contrib/gis/admin/__init__.py +6 −13 Original line number Diff line number Diff line # Getting the normal admin routines, classes, and `site` instance. from django.contrib.admin import ( # NOQA: flake8 detects only the last __all__ from django.contrib.admin import ( autodiscover, site, AdminSite, ModelAdmin, StackedInline, TabularInline, HORIZONTAL, VERTICAL, ) # Geographic admin options classes and widgets. from django.contrib.gis.admin.options import GeoModelAdmin # NOQA from django.contrib.gis.admin.widgets import OpenLayersWidget # NOQA from django.contrib.gis.admin.options import GeoModelAdmin, OSMGeoAdmin from django.contrib.gis.admin.widgets import OpenLayersWidget __all__ = [ "autodiscover", "site", "AdminSite", "ModelAdmin", "StackedInline", "TabularInline", "HORIZONTAL", "VERTICAL", "GeoModelAdmin", "OpenLayersWidget", "HAS_OSM", 'autodiscover', 'site', 'AdminSite', 'ModelAdmin', 'StackedInline', 'TabularInline', 'HORIZONTAL', 'VERTICAL', 'GeoModelAdmin', 'OSMGeoAdmin', 'OpenLayersWidget', ] try: from django.contrib.gis.admin.options import OSMGeoAdmin HAS_OSM = True __all__ += ['OSMGeoAdmin'] except ImportError: HAS_OSM = False django/contrib/gis/admin/options.py +16 −10 Original line number Diff line number Diff line Loading @@ -2,6 +2,9 @@ from django.contrib.admin import ModelAdmin from django.contrib.gis.admin.widgets import OpenLayersWidget from django.contrib.gis.db import models from django.contrib.gis.gdal import HAS_GDAL, OGRGeomType from django.core.exceptions import ImproperlyConfigured spherical_mercator_srid = 3857 class GeoModelAdmin(ModelAdmin): Loading Loading @@ -123,8 +126,6 @@ class GeoModelAdmin(ModelAdmin): } return OLMap if HAS_GDAL: spherical_mercator_srid = 3857 class OSMGeoAdmin(GeoModelAdmin): map_template = 'gis/admin/osm.html' Loading @@ -134,3 +135,8 @@ if HAS_GDAL: max_resolution = '156543.0339' point_zoom = num_zoom - 6 units = 'm' def __init__(self, *args): if not HAS_GDAL: raise ImproperlyConfigured("OSMGeoAdmin is not usable without GDAL libs installed") super(OSMGeoAdmin, self).__init__(*args) tests/gis_tests/geoadmin/models.py +3 −1 Original line number Diff line number Diff line from django.contrib.gis import admin from django.contrib.gis.db import models from django.contrib.gis.gdal import HAS_GDAL from django.utils.encoding import python_2_unicode_compatible Loading @@ -16,4 +17,5 @@ class City(models.Model): def __str__(self): return self.name if HAS_GDAL: admin.site.register(City, admin.OSMGeoAdmin) Loading
django/contrib/gis/admin/__init__.py +6 −13 Original line number Diff line number Diff line # Getting the normal admin routines, classes, and `site` instance. from django.contrib.admin import ( # NOQA: flake8 detects only the last __all__ from django.contrib.admin import ( autodiscover, site, AdminSite, ModelAdmin, StackedInline, TabularInline, HORIZONTAL, VERTICAL, ) # Geographic admin options classes and widgets. from django.contrib.gis.admin.options import GeoModelAdmin # NOQA from django.contrib.gis.admin.widgets import OpenLayersWidget # NOQA from django.contrib.gis.admin.options import GeoModelAdmin, OSMGeoAdmin from django.contrib.gis.admin.widgets import OpenLayersWidget __all__ = [ "autodiscover", "site", "AdminSite", "ModelAdmin", "StackedInline", "TabularInline", "HORIZONTAL", "VERTICAL", "GeoModelAdmin", "OpenLayersWidget", "HAS_OSM", 'autodiscover', 'site', 'AdminSite', 'ModelAdmin', 'StackedInline', 'TabularInline', 'HORIZONTAL', 'VERTICAL', 'GeoModelAdmin', 'OSMGeoAdmin', 'OpenLayersWidget', ] try: from django.contrib.gis.admin.options import OSMGeoAdmin HAS_OSM = True __all__ += ['OSMGeoAdmin'] except ImportError: HAS_OSM = False
django/contrib/gis/admin/options.py +16 −10 Original line number Diff line number Diff line Loading @@ -2,6 +2,9 @@ from django.contrib.admin import ModelAdmin from django.contrib.gis.admin.widgets import OpenLayersWidget from django.contrib.gis.db import models from django.contrib.gis.gdal import HAS_GDAL, OGRGeomType from django.core.exceptions import ImproperlyConfigured spherical_mercator_srid = 3857 class GeoModelAdmin(ModelAdmin): Loading Loading @@ -123,8 +126,6 @@ class GeoModelAdmin(ModelAdmin): } return OLMap if HAS_GDAL: spherical_mercator_srid = 3857 class OSMGeoAdmin(GeoModelAdmin): map_template = 'gis/admin/osm.html' Loading @@ -134,3 +135,8 @@ if HAS_GDAL: max_resolution = '156543.0339' point_zoom = num_zoom - 6 units = 'm' def __init__(self, *args): if not HAS_GDAL: raise ImproperlyConfigured("OSMGeoAdmin is not usable without GDAL libs installed") super(OSMGeoAdmin, self).__init__(*args)
tests/gis_tests/geoadmin/models.py +3 −1 Original line number Diff line number Diff line from django.contrib.gis import admin from django.contrib.gis.db import models from django.contrib.gis.gdal import HAS_GDAL from django.utils.encoding import python_2_unicode_compatible Loading @@ -16,4 +17,5 @@ class City(models.Model): def __str__(self): return self.name if HAS_GDAL: admin.site.register(City, admin.OSMGeoAdmin)