diff --git a/vendor/symposion/schedule/timetable.py b/vendor/symposion/schedule/timetable.py index b0488aae..9fcb627d 100644 --- a/vendor/symposion/schedule/timetable.py +++ b/vendor/symposion/schedule/timetable.py @@ -27,16 +27,16 @@ class TimeTable(object): times = sorted(set(itertools.chain(*self.slots_qs().values_list("start", "end")))) slots = Slot.objects.filter(pk__in=self.slots_qs().values("pk")) slots = slots.annotate(room_count=Count("slotroom"), order=Min("slotroom__room__order")) - slots = slots.order_by("start", "order") + slots = slots.order_by("order") row = [] total_room_count = self.rooms().count() for time, next_time in pairwise(times): row = {"time": time, "slots": []} - for slot in slots: - if slot.start == time: - slot.rowspan = TimeTable.rowspan(times, slot.start, slot.end) - slot.colspan = slot.room_count if not slot.exclusive else total_room_count - row["slots"].append(slot) + row_slots = [ slot for slot in slots if slot.start == time] + for slot in row_slots: + slot.rowspan = TimeTable.rowspan(times, slot.start, slot.end) + slot.colspan = slot.room_count if not slot.exclusive else total_room_count + row["slots"].append(slot) if row["slots"] or next_time is None: yield row