From 35c96f7db9a7d3199fc8e62f74bf29f407cf3918 Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Mon, 21 Mar 2011 16:18:38 +0100 Subject: added has_active_programslots to Show. diff --git a/program/admin.py b/program/admin.py index d3712ef..5a6ce7f 100644 --- a/program/admin.py +++ b/program/admin.py @@ -41,7 +41,7 @@ class ProgramSlotInline(admin.TabularInline): class ShowAdmin(admin.ModelAdmin): filter_horizontal = ('hosts', 'owners', 'musicfocus', 'showinformation', 'showtopic') inlines = (ProgramSlotInline,) - list_display = ('name', 'short_description', 'broadcastformat') + list_display = ('name', 'short_description', 'broadcastformat', 'has_active_programslots') list_filter = ('broadcastformat', 'showinformation', 'showtopic', 'musicfocus',) ordering = ('slug',) prepopulated_fields = {'slug': ('name',)} diff --git a/program/models.py b/program/models.py index 8aac8cc..1355e5a 100644 --- a/program/models.py +++ b/program/models.py @@ -2,7 +2,7 @@ from django.contrib.auth.models import User from django.db import models from django.utils.translation import ugettext_lazy as _ -from datetime import datetime +from datetime import date, datetime from dateutil.relativedelta import relativedelta from dateutil.rrule import rrule @@ -105,6 +105,11 @@ class Show(models.Model): def get_absolute_url(self): return ('show-detail', [self.slug]) + def has_active_programslots(self): + return self.programslots.filter(until__gt=date.today()).count() > 0 + has_active_programslots.boolean = True + has_active_programslots.short_description = _("Has active program slots") + class RRule(models.Model): FREQ_CHOICES = ( (1, _("Monthly")), -- cgit v0.10.2