summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/daily/admin.py24
-rw-r--r--app/utils/widgets.py13
2 files changed, 20 insertions, 17 deletions
diff --git a/app/daily/admin.py b/app/daily/admin.py
index 704d0dc..b61a2ad 100644
--- a/app/daily/admin.py
+++ b/app/daily/admin.py
@@ -1,15 +1,18 @@
from django.contrib import admin
-from django.contrib.gis.admin import OSMGeoAdmin
-from utils.widgets import LGEntryForm
+from utils.widgets import LGEntryForm, OLAdminBase
from .models import CheckIn, Daily, Weather
-class WeatherAdmin(OSMGeoAdmin):
+class WeatherAdmin(OLAdminBase):
pass
-class DailyAdmin(OSMGeoAdmin):
+class CheckInAdmin(OLAdminBase):
+ pass
+
+
+class DailyAdmin(admin.ModelAdmin):
form = LGEntryForm
list_display = ('date', 'user', 'location')
list_filter = (
@@ -46,19 +49,6 @@ class DailyAdmin(OSMGeoAdmin):
return qs.filter(user=request.user)
-class CheckInAdmin(OSMGeoAdmin):
- list_display = ('date', 'location')
- default_lon = -9285175
- default_lat = 4025046
- default_zoom = 15
- units = True
- scrollable = False
- map_width = 700
- map_height = 425
- map_template = 'gis/admin/osm.html'
- openlayers_url = '/static/admin/js/OpenLayers.js'
-
-
admin.site.register(CheckIn, CheckInAdmin)
admin.site.register(Weather, WeatherAdmin)
admin.site.register(Daily, DailyAdmin)
diff --git a/app/utils/widgets.py b/app/utils/widgets.py
index 90a0505..6d6a334 100644
--- a/app/utils/widgets.py
+++ b/app/utils/widgets.py
@@ -2,6 +2,7 @@ import os
from django import forms
from django.contrib import admin
from django.contrib.admin.widgets import AdminFileWidget
+from django.contrib.gis.admin import OSMGeoAdmin
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext_lazy as _
from django.conf import settings
@@ -91,3 +92,15 @@ class LGEntryForm(forms.ModelForm):
widgets = {
'body_markdown': forms.Textarea(attrs={'rows': 50, 'cols': 100}),
}
+
+
+class OLAdminBase(OSMGeoAdmin):
+ default_lon = -9285175
+ default_lat = 4025046
+ default_zoom = 15
+ units = True
+ scrollable = False
+ map_width = 700
+ map_height = 425
+ map_template = 'gis/admin/osm.html'
+ openlayers_url = '/static/admin/js/OpenLayers.js'