From 4261cdac6e396294fe5f1b4fc3fcfdfaac6526c4 Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Sat, 20 Aug 2016 21:24:34 +0200 Subject: added methods to list only active shows of a host and only active program slots of a show. diff --git a/program/models.py b/program/models.py index 8f6a65b..19c51bb 100644 --- a/program/models.py +++ b/program/models.py @@ -225,6 +225,9 @@ class Host(models.Model): def get_absolute_url(self): return reverse('host-detail', args=[str(self.id)]) + def active_shows(self): + return self.shows.filter(programslots__until__gt=datetime.today()) + class Show(models.Model): predecessor = models.ForeignKey('self', blank=True, null=True, related_name='successors', verbose_name=_("Predecessor")) @@ -256,6 +259,9 @@ class Show(models.Model): def get_absolute_url(self): return reverse('show-detail', args=[self.slug]) + def active_programslots(self): + return self.programslots.filter(until__gt=date.today()).distinct() + class RRule(models.Model): FREQ_CHOICES = ( -- cgit v0.10.2