from django.contrib import admin from django.contrib.gis.admin import OSMGeoAdmin from locations.models import Region,Country,Location,State,Route from django.contrib.gis.maps.google import GoogleMap from django.conf import settings GMAP = GoogleMap(key=settings.GOOGLE_MAPS_API_KEY) class RegionAdmin(OSMGeoAdmin): # Standard Django Admin Options list_display = ('name','slug') prepopulated_fields = {'slug': ('name',)} search_fields = ('name',) ordering = ('name',) save_as = True search_fields = ['name',] list_select_related = True fieldsets = ( ('Region', {'fields': ('name','slug','pub_date'), 'classes': ('show','extrapretty')}), ('Editable Map View', {'fields': ('geometry',), 'classes': ('show', 'wide')}), ) extra_js = [GMAP.api_url + GMAP.key] map_template = 'gis/admin/google.html' # Default GeoDjango OpenLayers map options # Uncomment and modify as desired # To learn more about this jargon visit: # www.openlayers.org #default_lon = 0 #default_lat = 0 #default_zoom = 4 #display_wkt = False #display_srid = False #extra_js = [] #num_zoom = 18 #max_zoom = False #min_zoom = False #units = False #max_resolution = False #max_extent = False #modifiable = True #mouse_position = True #scale_text = True #layerswitcher = True scrollable = False #admin_media_prefix = settings.ADMIN_MEDIA_PREFIX map_width = 700 map_height = 325 #map_srid = 4326 #map_template = 'gis/admin/openlayers.html' #openlayers_url = 'http://openlayers.org/api/2.6/OpenLayers.js' #wms_url = 'http://labs.metacarta.com/wms/vmap0' #wms_layer = 'basic' #wms_name = 'OpenLayers WMS' #debug = False #widget = OpenLayersWidget # Finally, with these options set now register the model # associating the Options with the actual model admin.site.register(Region,RegionAdmin) class CountryAdmin(OSMGeoAdmin): """ # Standard Django Admin Options list_display = ('name','slug','region') prepopulated_fields = {'slug': ('name',)} search_fields = ('name',) ordering = ('name',) save_as = True search_fields = ['name',] list_select_related = True fieldsets = ( ('Country', {'fields': ('name','slug','abbr','region','pub_date'), 'classes': ('show','extrapretty')}), ('Editable Map View', {'fields': ('geometry',), 'classes': ('show', 'wide')}), ) """ # Standard Django Admin Options list_display = ('name','pop2005','region','subregion',) search_fields = ('name',) ordering = ('name',) list_filter = ('visited','region','subregion',) save_as = True search_fields = ['name','iso2','iso3','subregion','region'] list_select_related = True fieldsets = ( ('Country Attributes', {'fields': (('name','pop2005','slug','zoom_level','visited')), 'classes': ('show','extrapretty')}), ('Country Codes', {'fields': ('region','subregion','iso2','iso3','un',), 'classes': ('collapse',)}), ('Area and Coordinates', {'fields': ('area','lat','lon',), 'classes': ('collapse', 'wide')}), ('Editable Map View', {'fields': ('geometry',), 'classes': ('show', 'wide')}), ) extra_js = [GMAP.api_url + GMAP.key] map_template = 'gis/admin/google.html' # Default GeoDjango OpenLayers map options # Uncomment and modify as desired # To learn more about this jargon visit: # www.openlayers.org #default_lon = 0 #default_lat = 0 #default_zoom = 4 #display_wkt = False #display_srid = False #extra_js = [] #num_zoom = 18 #max_zoom = False #min_zoom = False #units = False #max_resolution = False #max_extent = False #modifiable = True #mouse_position = True #scale_text = True #layerswitcher = True scrollable = False #admin_media_prefix = settings.ADMIN_MEDIA_PREFIX map_width = 700 map_height = 325 #map_srid = 4326 #map_template = 'gis/admin/openlayers.html' #openlayers_url = 'http://openlayers.org/api/2.6/OpenLayers.js' #wms_url = 'http://labs.metacarta.com/wms/vmap0' #wms_layer = 'basic' #wms_name = 'OpenLayers WMS' #debug = False #widget = OpenLayersWidget # Finally, with these options set now register the model # associating the Options with the actual model admin.site.register(Country,CountryAdmin) class StateAdmin(OSMGeoAdmin): # Standard Django Admin Options list_display = ('name','code','slug','country') prepopulated_fields = {'slug': ('name',)} search_fields = ('name','country') ordering = ('name',) save_as = True search_fields = ['name',] list_select_related = True fieldsets = ( ('Location', {'fields': ('name','slug','code','pub_date','country'), 'classes': ('show','extrapretty')}), ('Editable Map View', {'fields': ('geometry',), 'classes': ('show', 'wide')}), ) extra_js = [GMAP.api_url + GMAP.key] map_template = 'gis/admin/google.html' # Default GeoDjango OpenLayers map options # Uncomment and modify as desired # To learn more about this jargon visit: # www.openlayers.org #default_lon = 0 #default_lat = 0 #default_zoom = 4 #display_wkt = False #display_srid = False #extra_js = [] #num_zoom = 18 #max_zoom = False #min_zoom = False #units = False #max_resolution = False #max_extent = False #modifiable = True #mouse_position = True #scale_text = True #layerswitcher = True scrollable = False #admin_media_prefix = settings.ADMIN_MEDIA_PREFIX map_width = 700 map_height = 325 #map_srid = 4326 #map_template = 'gis/admin/openlayers.html' #openlayers_url = 'http://openlayers.org/api/2.6/OpenLayers.js' #wms_url = 'http://labs.metacarta.com/wms/vmap0' #wms_layer = 'basic' #wms_name = 'OpenLayers WMS' #debug = False #widget = OpenLayersWidget # Finally, with these options set now register the model # associating the Options with the actual model admin.site.register(State,StateAdmin) class LocationAdmin(OSMGeoAdmin): # Standard Django Admin Options list_display = ('name','slug','state') prepopulated_fields = {'slug': ('name',)} search_fields = ('name','state') ordering = ('name',) save_as = True search_fields = ['name',] list_select_related = True fieldsets = ( ('Location', {'fields': ('name','slug','pub_date','state'), 'classes': ('show','extrapretty')}), ('Editable Map View', {'fields': ('geometry',), 'classes': ('show', 'wide')}), ) extra_js = [GMAP.api_url + GMAP.key] map_template = 'gis/admin/google.html' # Default GeoDjango OpenLayers map options # Uncomment and modify as desired # To learn more about this jargon visit: # www.openlayers.org #default_lon = 0 #default_lat = 0 #default_zoom = 4 #display_wkt = False #display_srid = False #extra_js = [] #num_zoom = 18 #max_zoom = False #min_zoom = False #units = False #max_resolution = False #max_extent = False #modifiable = True #mouse_position = True #scale_text = True #layerswitcher = True scrollable = False #admin_media_prefix = settings.ADMIN_MEDIA_PREFIX map_width = 700 map_height = 325 #map_srid = 4326 #map_template = 'gis/admin/openlayers.html' #openlayers_url = 'http://openlayers.org/api/2.6/OpenLayers.js' #wms_url = 'http://labs.metacarta.com/wms/vmap0' #wms_layer = 'basic' #wms_name = 'OpenLayers WMS' #debug = False #widget = OpenLayersWidget # Finally, with these options set now register the model # associating the Options with the actual model admin.site.register(Location,LocationAdmin) class RouteAdmin(OSMGeoAdmin): # Standard Django Admin Options list_display = ('name','slug',) prepopulated_fields = {'slug': ('name',)} search_fields = ('name',) ordering = ('name',) save_as = True search_fields = ['name',] list_select_related = True fieldsets = ( ('Location', {'fields': ('name','slug','pub_date','template_var_name','zoom'), 'classes': ('show','extrapretty')}), ('Editable Map View', {'fields': ('geometry',), 'classes': ('show', 'wide')}), ) extra_js = [GMAP.api_url + GMAP.key] map_template = 'gis/admin/google.html' # Default GeoDjango OpenLayers map options # Uncomment and modify as desired # To learn more about this jargon visit: # www.openlayers.org #default_lon = 0 #default_lat = 0 #default_zoom = 4 #display_wkt = False #display_srid = False #extra_js = [] #num_zoom = 18 #max_zoom = False #min_zoom = False #units = False #max_resolution = False #max_extent = False #modifiable = True #mouse_position = True #scale_text = True #layerswitcher = True scrollable = False #admin_media_prefix = settings.ADMIN_MEDIA_PREFIX map_width = 700 map_height = 325 #map_srid = 4326 #map_template = 'gis/admin/openlayers.html' #openlayers_url = 'http://openlayers.org/api/2.6/OpenLayers.js' #wms_url = 'http://labs.metacarta.com/wms/vmap0' #wms_layer = 'basic' #wms_name = 'OpenLayers WMS' #debug = False #widget = OpenLayersWidget # Finally, with these options set now register the model # associating the Options with the actual model admin.site.register(Route,RouteAdmin)