From 2c8661d1e17cdd26d5f347d8a5fb332b5d267fe6 Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Sat, 18 Jun 2011 15:44:05 +0200 Subject: made note administration more usable diff --git a/program/admin.py b/program/admin.py index 6c64dd3..63fc2e2 100644 --- a/program/admin.py +++ b/program/admin.py @@ -1,6 +1,6 @@ from django.contrib import admin -from datetime import datetime +from datetime import datetime, timedelta from models import BroadcastFormat, MusicFocus, ShowInformation, ShowTopic, Host, Note, ProgramSlot, Show, TimeSlot @@ -22,8 +22,9 @@ class ShowTopicAdmin(admin.ModelAdmin): class NoteAdmin(admin.ModelAdmin): date_hierarchy = 'start' + exclude = ('owner',) list_display = ('title', 'show', 'start', 'status') - list_filter = ('status',) + list_filter = ('status', 'show') ordering = ('timeslot',) def queryset(self, request): @@ -36,11 +37,12 @@ class NoteAdmin(admin.ModelAdmin): def formfield_for_foreignkey(self, db_field, request, **kwargs): if db_field.name == 'timeslot': + one_year_ago = datetime.today() - timedelta(days=365) if request.user.is_superuser: - kwargs['queryset'] = TimeSlot.objects.filter(start__gt=datetime.now) + kwargs['queryset'] = TimeSlot.objects.filter(start__gt=one_year_ago, note__isnull=True) else: shows = request.user.shows.all() - kwargs['queryset'] = TimeSlot.objects.filter(show__in=shows, start__gt=datetime.now) + kwargs['queryset'] = TimeSlot.objects.filter(show__in=shows, start__gt=one_year_ago, note__isnull=True) return super(NoteAdmin, self).formfield_for_foreignkey(db_field, request, **kwargs) -- cgit v0.10.2