more chnages

This commit is contained in:
Talhadeveloperr
2026-09-09 17:07:11 +05:00
parent a7bb2f3dae
commit 1c5b8f38c8
57 changed files with 147 additions and 31 deletions

View File

@@ -17,18 +17,26 @@ def generate_room_wise_templates(sessions, data, output_dir):
room_id = room["room_id"]
room_sessions = [s for s in sessions if s["room_id"] == room_id]
# A room-wise view can legitimately show more than one lecture in
# the same slot (e.g. a large room split/shared), so every session
# landing on a cell is kept and rendered — none are dropped.
by_day_slot = {}
for s in room_sessions:
for slot_index in s["slot_indices"]:
by_day_slot[(s["day"], slot_index)] = s
by_day_slot.setdefault((s["day"], slot_index), []).append(s)
def cell_text(day, slot_index, by_day_slot=by_day_slot):
s = by_day_slot.get((day, slot_index))
if not s:
entries = by_day_slot.get((day, slot_index))
if not entries:
return ""
tag = " (Lab)" if s["course_type"] == "lab" else (" (General)" if s["is_general"] else "")
batches = "+".join(s["batch_codes"])
return f'{s["course_name"]}{tag}\n{batches}\n{s["instructor_name"]}'
lines = []
for s in entries:
tag = " (Lab)" if s["course_type"] == "lab" else (" (General)" if s["is_general"] else "")
batches = "+".join(s["batch_codes"])
lines.append(f'{s["course_name"]}{tag}\n{batches}\n{s["instructor_name"]}')
return "\n---\n".join(lines)
first_by_day_slot = {k: v[0] for k, v in by_day_slot.items()}
wb = new_workbook()
ws = wb.active
@@ -37,7 +45,7 @@ def generate_room_wise_templates(sessions, data, output_dir):
title=f'{room["room_name"]} ({room_id})',
subtitle=f'Block {room["block_id"]} - {room["room_type"].title()} - Capacity {room["capacity"]}',
time_slots=GRID_TIME_SLOTS,
sessions_by_day_slot=by_day_slot,
sessions_by_day_slot=first_by_day_slot,
cell_text_fn=cell_text,
)
path = save_workbook(wb, output_dir, f"{room_id}.xlsx")