# last step is adding nonstop zones between slots
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)]
dt = dt.replace(hour=dawn.hour, minute=dawn.minute)
cells.append(cls(nonstop, dt))
+ cells.sort(key=lambda x: x.datetime)
return cells
if slot_end < next_slot.datetime:
next_day_start = next_slot.datetime.replace(hour=5, minute=0)
if slot_end < next_day_start and next_slot.datetime > next_day_start:
- program[i+1:i+1] = NonstopSlot.get_serie(slot_end, next_day_start) + \
- NonstopSlot.get_serie(next_day_start, next_slot.datetime)
+ nonstop_day_slots = NonstopSlot.get_serie(slot_end, next_day_start)
+ nonstop_next_day_slots = NonstopSlot.get_serie(next_day_start, next_slot.datetime)
+ if nonstop_day_slots and nonstop_next_day_slots and \
+ nonstop_day_slots[-1].label == nonstop_next_day_slots[0].label:
+ nonstop_next_day_slots = nonstop_next_day_slots[1:]
+ program[i+1:i+1] = nonstop_day_slots + nonstop_next_day_slots
else:
program[i+1:i+1] = NonstopSlot.get_serie(slot_end, next_slot.datetime)