diff options
author | Ernesto Rico-Schmidt <e.rico.schmidt@gmail.com> | 2011-03-21 15:18:38 (GMT) |
---|---|---|
committer | Ernesto Rico-Schmidt <e.rico.schmidt@gmail.com> | 2011-03-21 15:18:38 (GMT) |
commit | 35c96f7db9a7d3199fc8e62f74bf29f407cf3918 (patch) | |
tree | 907174851579cf7ffb1c1ce9cecaf862b6823aea | |
parent | 4d63cb721d78a8bf6d5b4af095fde07c72abf13c (diff) |
added has_active_programslots to Show.
-rw-r--r-- | program/admin.py | 2 | ||||
-rw-r--r-- | program/models.py | 7 |
2 files changed, 7 insertions, 2 deletions
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")), |