Changeset - 44d0ea6f2b8e
[Not reviewed]
0 1 0
Brian Rosner - 12 years ago 2012-08-30 07:02:49
brosner@gmail.com
Moved colspan to slot in TimeTable
1 file changed with 1 insertions and 1 deletions:
0 comments (0 inline, 0 general)
symposion/schedule/timetable.py
Show inline comments
...
 
@@ -14,26 +14,26 @@ class TimeTable(object):
 
    def rooms(self):
 
        return Room.objects.filter(schedule=self.day.schedule).order_by("order")
 
    
 
    def __iter__(self):
 
        times = sorted(set(itertools.chain(*self.slots_qs().values_list("start", "end"))))
 
        slots = list(self.slots_qs().order_by("start"))
 
        row = []
 
        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.rooms.consecutive_count()
 
                    row["slots"].append(slot)
 
            row["colspan"] = self.rooms.consecutive_count()
 
            if row["slots"] or next_time is None:
 
                yield row
 
    
 
    @staticmethod
 
    def rowspan(times, start, end):
 
        return times.index(end) - times.index(start)
 

	
 

	
 
def pairwise(iterable):
 
    a, b = itertools.tee(iterable)
 
    b.next()
 
    return itertools.izip_longest(a, b)
0 comments (0 inline, 0 general)