diff options
author | Ernesto Rico-Schmidt <e.rico.schmidt@gmail.com> | 2013-03-09 21:39:15 (GMT) |
---|---|---|
committer | Ernesto Rico-Schmidt <e.rico.schmidt@gmail.com> | 2013-03-09 21:39:15 (GMT) |
commit | 100a5776d1e06f2738592bf40537305a61ed93ea (patch) | |
tree | e324cdac81b7927ec3ef0a0a68bbdf5dfd3dc75b /program | |
parent | fbd9eece0669a4b2f32fd0edecba715d1dfe915b (diff) |
fixed index out range.
Diffstat (limited to 'program')
-rw-r--r-- | program/models.py | 11 |
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): |