from django.contrib import admin from django.contrib.gis.admin import OSMGeoAdmin from .models import Region, Country, Location, State, Route, CheckIn, Campsite from utils.widgets import OLAdminBase from utils.util import get_latlon from utils.widgets import LGEntryForm @admin.register(Region) class RegionAdmin(OSMGeoAdmin): 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' ) }), ) # options for OSM map Using custom ESRI topo map default_lon = -9285175 default_lat = 4025046 default_zoom = 6 units = True scrollable = False map_width = 700 map_height = 425 map_template = 'gis/admin/osm.html' openlayers_url = '/static/admin/js/OpenLayers.js' @admin.register(Country) class CountryAdmin(OSMGeoAdmin): 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' ) }), ) # Options for OSM map Using custom ESRI topo map default_lon = -9285175 default_lat = 4025046 default_zoom = 6 units = True scrollable = False map_width = 700 map_height = 425 map_template = 'gis/admin/osm.html' openlayers_url = '/static/admin/js/OpenLayers.js' @admin.register(State) class StateAdmin(OSMGeoAdmin): 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' ) }), ) # Options for OSM map Using custom ESRI topo map default_lon = -9285175 default_lat = 4025046 default_zoom = 6 units = True scrollable = False map_width = 700 map_height = 425 map_template = 'gis/admin/osm.html' openlayers_url = '/static/admin/js/OpenLayers.js' @admin.register(Location) class LocationAdmin(OSMGeoAdmin): list_display = ('name', 'pub_date', 'parent', 'state', 'slug') prepopulated_fields = {'slug': ('name',)} search_fields = ('name', 'state') ordering = ('pub_date', 'name') list_filter = ('pub_date', 'state__country__lux_region', 'state') save_as = True search_fields = ['name'] list_select_related = True fieldsets = ( ('Location', { 'fields': ( 'name', 'slug', 'pub_date', 'state', 'parent' ), 'classes': ('show', 'extrapretty') }), ('Editable Map View', { 'fields': ('geometry',), 'classes': ('show', 'wide') }), ) # options for OSM map Using custom ESRI topo map default_lat, default_lon = get_latlon() default_zoom = 6 units = True scrollable = False map_width = 700 map_height = 425 map_template = 'gis/admin/osm.html' openlayers_url = '/static/admin/js/OpenLayers.js' class Media: js = ('next-prev-links.js',) @admin.register(Route) class RouteAdmin(OSMGeoAdmin): 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') }), ) # options for OSM map Using custom ESRI topo map default_lon = -9285175 default_lat = 4025046 default_zoom = 6 units = True scrollable = False map_width = 700 map_height = 425 map_template = 'gis/admin/osm.html' openlayers_url = '/static/admin/js/OpenLayers.js' @admin.register(CheckIn) class CheckInAdmin(OLAdminBase): list_display = ('date', 'location') # options for OSM map Using custom ESRI topo map default_lat, default_lon = get_latlon() default_zoom = 9 @admin.register(Campsite) class CampsiteAdmin(OLAdminBase): form = LGEntryForm list_display = ('name', 'location', 'date_arrived', 'campsite_type',) list_filter = ('date_arrived', 'campsite_type') search_fields = ['location__name', ] fieldsets = ( ('Campsite', { 'fields': ( 'name', ('date_arrived', 'date_left'), 'point', 'campsite_type', 'campsite_number', 'campsite_we_wish_we_had', 'body_markdown' ), 'classes': ( 'show', 'extrapretty', 'wide' ) } ), ) default_lat, default_lon = get_latlon() default_zoom = 9 class Media: js = ('image-loader.js', 'next-prev-links.js')