1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
from django.contrib import admin
from django.contrib.gis.admin import OSMGeoAdmin
from utils.widgets import LGEntryForm
from .models import CheckIn, Daily, Weather
class WeatherAdmin(OSMGeoAdmin):
pass
class DailyAdmin(OSMGeoAdmin):
form = LGEntryForm
list_display = ('date', 'user', 'location')
list_filter = (
'date',
('location', admin.RelatedOnlyFieldListFilter),
)
fieldsets = (
(None, {
'fields': (
'user',
'body_markdown',
'weather_human',
)
}),
('Details', {
'fields': (
'location',
'weather',
'date'
),
'classes': ('collapse',),
}),
)
def get_form(self, request, obj=None, **kwargs):
form = super(DailyAdmin, self).get_form(request, **kwargs)
form.current_user = request.user
return form
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)
|