dashboard - whole redesign and rewrite

This commit is contained in:
2026-09-04 13:15:08 +02:00
parent 87fc43db87
commit 01b4be301f
9 changed files with 273 additions and 99 deletions
+22 -21
View File
@@ -61,12 +61,11 @@ def has_style(value, declaration):
def event_rows(cell):
blocks = cell.find_all("div", class_="calEventBox")
titles = cell.find_all(style=lambda value: has_style(value, "margin-right:.2em"))
for index, title in enumerate(titles):
time_text, place = "", "--"
block = blocks[index] if index < len(blocks) else None
titles = cell.find_all(style=lambda value: has_style(value, "margin-right:.2em"))
for title in titles:
time_text = ""
block = title.find_parent("div", class_="calEventBox")
details = block and block.find(
style=lambda value: has_style(value, "font-weight:normal")
)
@@ -74,9 +73,10 @@ def event_rows(cell):
parts = [part.strip() for part in details.stripped_strings if part.strip()]
if parts and ":" in parts[0]:
time_text = parts.pop(0)
if parts:
place = parts[0].lstrip(", ") or "--"
yield time_text, title.get_text(strip=True), place
# Nur das Ortsfeld auswerten, nicht Trennzeichen, Datumsbereiche oder Notizen.
location = block and block.find(attrs={"name": "show_place"})
place = location.get_text(" ", strip=True).lstrip(", ") if location else ""
yield time_text, title.get_text(strip=True), "" if place == "--" else place
def next_month(month):
@@ -204,10 +204,14 @@ def add_month(pdf, cells, month, today=None):
def add_month_section(pdf, cells, month, now, today=None, planning_note=False):
name = MONTHS[month.month - 1]
pdf.set_font("helvetica", "B", 16)
pdf.cell(160, 7, pdf_safe(f"Terminübersicht: {name.upper()} {month.year}"), 0, 1)
pdf.set_font("helvetica", "", 10)
name = MONTHS[month.month - 1]
pdf.set_font("helvetica", "B", 16)
pdf.cell(160, 7, pdf_safe(f"Terminübersicht: {name.upper()} {month.year}"), 0, 1)
logo = os.path.join(os.path.dirname(__file__), "nak_logo.png")
if not os.path.isfile(logo):
raise RuntimeError(f"Logo fehlt: {logo}")
pdf.image(logo, 188, pdf.get_y() - 7.5, 11)
pdf.set_font("helvetica", "", 10)
subtitle = (
f"Die Termine für {name} befinden sich noch in Planung und können sich ändern."
if planning_note else "der Gemeinde Berlin-Reinickendorf"
@@ -230,14 +234,11 @@ def create_pdf(cells, output_path, now=None):
pdf.set_auto_page_break(auto=True, margin=15)
pdf.add_page()
logo = os.path.join(os.path.dirname(__file__), "nak_logo.png")
if not os.path.isfile(logo):
raise RuntimeError(f"Logo fehlt: {logo}")
pdf.image(logo, 188, 9.5, 11)
for index, month in enumerate(months):
if index:
pdf.cell(0, 6, " ", 0, 1)
for index, month in enumerate(months):
if index and pdf.page_no() == 1:
pdf.add_page()
elif index:
pdf.cell(0, 6, " ", 0, 1)
add_month_section(
pdf, cells, month, now,
today=today if index == 0 else None,