summaryrefslogtreecommitdiff
path: root/app/locations/admin.py
diff options
context:
space:
mode:
Diffstat (limited to 'app/locations/admin.py')
-rw-r--r--app/locations/admin.py56
1 files changed, 43 insertions, 13 deletions
diff --git a/app/locations/admin.py b/app/locations/admin.py
index 4adb836..f970130 100644
--- a/app/locations/admin.py
+++ b/app/locations/admin.py
@@ -1,10 +1,14 @@
from django.contrib import admin
from django.contrib.gis.admin import OSMGeoAdmin
-from locations.models import Region, Country, Location, State, Route, CheckIn
-from utils.widgets import OLAdminBase
+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',)}
@@ -45,9 +49,8 @@ class RegionAdmin(OSMGeoAdmin):
map_template = 'gis/admin/osm.html'
openlayers_url = '/static/admin/js/OpenLayers.js'
-admin.site.register(Region, RegionAdmin)
-
+@admin.register(Country)
class CountryAdmin(OSMGeoAdmin):
list_display = ('name', 'pop2005', 'region', 'subregion')
search_fields = ('name',)
@@ -112,9 +115,7 @@ class CountryAdmin(OSMGeoAdmin):
openlayers_url = '/static/admin/js/OpenLayers.js'
-admin.site.register(Country, CountryAdmin)
-
-
+@admin.register(State)
class StateAdmin(OSMGeoAdmin):
list_display = ('name', 'code', 'slug', 'country')
prepopulated_fields = {'slug': ('name',)}
@@ -157,9 +158,8 @@ class StateAdmin(OSMGeoAdmin):
map_template = 'gis/admin/osm.html'
openlayers_url = '/static/admin/js/OpenLayers.js'
-admin.site.register(State, StateAdmin)
-
+@admin.register(Location)
class LocationAdmin(OSMGeoAdmin):
list_display = ('name', 'pub_date', 'parent', 'state', 'slug')
prepopulated_fields = {'slug': ('name',)}
@@ -198,9 +198,8 @@ class LocationAdmin(OSMGeoAdmin):
class Media:
js = ('next-prev-links.js',)
-admin.site.register(Location, LocationAdmin)
-
+@admin.register(Route)
class RouteAdmin(OSMGeoAdmin):
list_display = ('name', 'slug')
prepopulated_fields = {'slug': ('name',)}
@@ -237,8 +236,6 @@ class RouteAdmin(OSMGeoAdmin):
map_template = 'gis/admin/osm.html'
openlayers_url = '/static/admin/js/OpenLayers.js'
-admin.site.register(Route, RouteAdmin)
-
@admin.register(CheckIn)
class CheckInAdmin(OLAdminBase):
@@ -246,3 +243,36 @@ class CheckInAdmin(OLAdminBase):
# 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')