summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErnesto Rico-Schmidt <e.rico.schmidt@gmail.com>2013-03-09 21:39:15 (GMT)
committerErnesto Rico-Schmidt <e.rico.schmidt@gmail.com>2013-03-09 21:39:15 (GMT)
commit100a5776d1e06f2738592bf40537305a61ed93ea (patch)
treee324cdac81b7927ec3ef0a0a68bbdf5dfd3dc75b
parentfbd9eece0669a4b2f32fd0edecba715d1dfe915b (diff)
fixed index out range.
-rw-r--r--program/models.py11
1 files changed, 7 insertions, 4 deletions
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):