diff options
Diffstat (limited to 'bak/unused_apps/daily/admin.py')
-rw-r--r-- | bak/unused_apps/daily/admin.py | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/bak/unused_apps/daily/admin.py b/bak/unused_apps/daily/admin.py new file mode 100644 index 0000000..32a5747 --- /dev/null +++ b/bak/unused_apps/daily/admin.py @@ -0,0 +1,55 @@ +from django.contrib import admin + +from utils.widgets import LGEntryForm, OLAdminBase +from .models import CheckIn, Daily, Weather + + +class WeatherAdmin(OLAdminBase): + pass + + +class CheckInAdmin(OLAdminBase): + list_display = ('date', 'location') + pass + + +class DailyAdmin(admin.ModelAdmin): + 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 + + def get_queryset(self, request): + qs = super(DailyAdmin, self).get_queryset(request) + if request.user.is_superuser: + return qs + return qs.filter(user=request.user) + + +admin.site.register(CheckIn, CheckInAdmin) +admin.site.register(Weather, WeatherAdmin) +admin.site.register(Daily, DailyAdmin) |