Order slots by room order first
* lca2018 has a situation where we have multiple slots starting at the same time, but ending at different times * The headers of the timetable grid are sorted by room sort order * In sqlite at least, ordering by start,order seems to implicitly resolve duplicate start times by looking at the other sort fields first, and will only sort on order if all other fields are identical * This results in the slot that ends first going in column 1, which gets out of sync with the room listed in the header * I can't figure out how to solve this in the database, so... * Force the slots to be sorted by room order. * Then, for each start_time, select out slots starting at that time and operate on them * This both gets the slots in the right order *and* keeps multi-room slots with the right colspan. Yay! * It's possible that this wouldn't be needed on some DBs which might do the sorting differently.
This commit is contained in:
		
							parent
							
								
									f07246f9d5
								
							
						
					
					
						commit
						b833b7d869
					
				
					 1 changed files with 6 additions and 6 deletions
				
			
		
							
								
								
									
										12
									
								
								vendor/symposion/schedule/timetable.py
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										12
									
								
								vendor/symposion/schedule/timetable.py
									
										
									
									
										vendored
									
									
								
							|  | @ -27,16 +27,16 @@ class TimeTable(object): | ||||||
|         times = sorted(set(itertools.chain(*self.slots_qs().values_list("start", "end")))) |         times = sorted(set(itertools.chain(*self.slots_qs().values_list("start", "end")))) | ||||||
|         slots = Slot.objects.filter(pk__in=self.slots_qs().values("pk")) |         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.annotate(room_count=Count("slotroom"), order=Min("slotroom__room__order")) | ||||||
|         slots = slots.order_by("start", "order") |         slots = slots.order_by("order") | ||||||
|         row = [] |         row = [] | ||||||
|         total_room_count = self.rooms().count() |         total_room_count = self.rooms().count() | ||||||
|         for time, next_time in pairwise(times): |         for time, next_time in pairwise(times): | ||||||
|             row = {"time": time, "slots": []} |             row = {"time": time, "slots": []} | ||||||
|             for slot in slots: |             row_slots = [ slot for slot in slots if slot.start == time] | ||||||
|                 if slot.start == time: |             for slot in row_slots: | ||||||
|                     slot.rowspan = TimeTable.rowspan(times, slot.start, slot.end) |                 slot.rowspan = TimeTable.rowspan(times, slot.start, slot.end) | ||||||
|                     slot.colspan = slot.room_count if not slot.exclusive else total_room_count |                 slot.colspan = slot.room_count if not slot.exclusive else total_room_count | ||||||
|                     row["slots"].append(slot) |                 row["slots"].append(slot) | ||||||
|             if row["slots"] or next_time is None: |             if row["slots"] or next_time is None: | ||||||
|                 yield row |                 yield row | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 James Polley
						James Polley