diff options
author | Ernesto Rico-Schmidt <ernesto.rico-schmidt@evolaris.net> | 2016-08-20 19:24:34 (GMT) |
---|---|---|
committer | Ernesto Rico-Schmidt <ernesto.rico-schmidt@evolaris.net> | 2016-08-20 19:29:55 (GMT) |
commit | 4261cdac6e396294fe5f1b4fc3fcfdfaac6526c4 (patch) | |
tree | ed1bef6cad74eea41374e049e91a929bdd14c02c | |
parent | 0c2a864cc58acf436d49a09877ca55dd2c3b4fc4 (diff) |
added methods to list only active shows of a host and only active program slots of a show.
-rw-r--r-- | program/models.py | 6 |
1 files changed, 6 insertions, 0 deletions
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 = ( |