From 15e7ce4196b590f8e7abdf9fecde40d657ce4e5a Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Wed, 28 Dec 2011 11:32:23 -0400 Subject: added renew action to TimeSlot admin diff --git a/program/admin.py b/program/admin.py index b50e14f..cec7857 100644 --- a/program/admin.py +++ b/program/admin.py @@ -1,7 +1,10 @@ from django.contrib import admin +from django.utils.translation import ugettext_lazy as _ from models import BroadcastFormat, MusicFocus, ShowInformation, ShowTopic, Host, Note, ProgramSlot, Show, TimeSlot +from datetime import date + class BroadcastFormatAdmin(admin.ModelAdmin): list_display = ('format',) prepopulated_fields = {'slug': ('format',)} @@ -46,7 +49,13 @@ class TimeSlotInline(admin.TabularInline): model = TimeSlot readonly_fields = ('start', 'end') +def renew(modeladmin, request, queryset): + next_year = date.today().year+1 + queryset.update(until=date(next_year, 12, 31)) +renew.short_description = _("Renew selected time slots") + class ProgramSlotAdmin(admin.ModelAdmin): + actions = (renew,) inlines = (TimeSlotInline,) list_display = ('show', 'byweekday', 'rrule', 'tstart', 'tend', 'dstart', 'until', 'timeslot_count') list_filter = ('byweekday', 'rrule', 'is_repetition') -- cgit v0.10.2