From 100a5776d1e06f2738592bf40537305a61ed93ea Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Sat, 9 Mar 2013 22:39:15 +0100 Subject: fixed index out range. diff --git a/program/models.py b/program/models.py index 3d71911..c176fda 100644 --- a/program/models.py +++ b/program/models.py @@ -373,10 +373,13 @@ class ProgramSlot(models.Model): timeslot_count.description = _("Time slot count") def has_active_timeslot(self): - start = self.timeslots.all().order_by("start")[0].start - end = self.timeslots.all().order_by("-end")[0].end - now = datetime.now() - return (start < now and end > now) + if self.timeslots.count() > 0: + start = self.timeslots.all().order_by("start")[0].start + end = self.timeslots.all().order_by("-end")[0].end + now = datetime.now() + return (start < now and end > now) + else: + return False class TimeSlotManager(models.Manager): def get_or_create_current(self): -- cgit v0.10.2