Commit d7480c98 authored by fred's avatar fred

don't crash when there are no nonstop zones

parent 06641a2e
......@@ -221,8 +221,11 @@ def period_program(date_start, date_end, prefetch_sounds=True,
nonstops = list(Nonstop.objects.all().order_by('start'))
nonstops = [x for x in nonstops if x.start != x.end]
dawn = time(Schedule.DAY_HOUR_START, 0)
first_of_the_day = [x for x in nonstops if x.start <= dawn][-1]
nonstops = nonstops[nonstops.index(first_of_the_day):] + nonstops[:nonstops.index(first_of_the_day)]
except IndexError:
class NonstopSlot(WeekdayMixin):
def __init__(self, nonstop, dt):
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment