diff options
author | Ernesto Rico-Schmidt <e.rico.schmidt@gmail.com> | 2011-06-18 13:44:05 (GMT) |
---|---|---|
committer | Ernesto Rico-Schmidt <e.rico.schmidt@gmail.com> | 2011-06-18 13:44:05 (GMT) |
commit | 2c8661d1e17cdd26d5f347d8a5fb332b5d267fe6 (patch) | |
tree | 077b36382d33d5713d4373be240a8c579b4c4f73 | |
parent | 786ab8d4a6f05e6cb8ab138cd4ef78ea5e24b531 (diff) |
made note administration more usable
-rw-r--r-- | program/admin.py | 10 |
1 files changed, 6 insertions, 4 deletions
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) |