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)]
+ try:
+ 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:
+ pass
class NonstopSlot(WeekdayMixin):
def __init__(self, nonstop, dt):