diff --git a/app/main.py b/app/main.py index 493e92e..43968d0 100644 --- a/app/main.py +++ b/app/main.py @@ -498,6 +498,21 @@ def api_verbands(kz: str = Query(...), sem: str = Query("")): return client.verbands_for(kz, sem) +def _lektor_uid(name: str) -> str: + """Anzeigename eines Lektors (Titel + Vor- + Nachname) → Username.""" + n = (name or "").strip().lower() + if not n: + return "" + best, best_len = "", 0 + for b in client.benutzer_all(): + if b["uid"].isdigit() or not (b["vorname"] and b["nachname"]): + continue + full = f"{b['vorname']} {b['nachname']}".lower() + if (n.endswith(full) or full in n) and len(full) > best_len: + best, best_len = b["uid"], len(full) + return best + + @app.get("/api/detail") def api_detail(kind: str = "student", datum: str = "", stunde: int = 0, uid: str = "", kz: str = "", sem: str = "", ver: str = "", @@ -514,7 +529,10 @@ def api_detail(kind: str = "student", datum: str = "", stunde: int = 0, grp = grp or p.gruppe try: rows = client.detail(kind, datum, stunde, uid, kz, sem, ver, grp, ort) - return {"rows": rows} + out = {"rows": rows} + if rows.get("LektorIn"): + out["lektor_uid"] = _lektor_uid(rows["LektorIn"]) + return out except Exception as e: return JSONResponse({"error": str(e)}, status_code=502) diff --git a/app/static/app.js b/app/static/app.js index 24480b0..1355e8c 100644 --- a/app/static/app.js +++ b/app/static/app.js @@ -291,12 +291,15 @@ async function openEvent(ev) { const j = await r.json(); if (j.error) throw new Error(j.error); const rows = j.rows || {}; + const lektorCell = rows["LektorIn"] ? (j.lektor_uid + ? `${esc(rows["LektorIn"])}` + : esc(rows["LektorIn"])) : null; body.innerHTML = ` - ${rows["LektorIn"] ? `` : ""} + ${lektorCell ? `` : ""} ${rows["Ort"] ? `` : ""} ${rows["Lehrfach"] ? `` : ""} ${rows["Bezeichnung"] ? `` : ""} diff --git a/app/templates/liste.html b/app/templates/liste.html index 42e6d22..4928978 100644 --- a/app/templates/liste.html +++ b/app/templates/liste.html @@ -67,8 +67,13 @@ {% set dec = decode_matrikel(st.matrikel, meta.stgs) %} + {% if st.matrikel %} + + + {% else %} + {% endif %}
Datum / Stunde${esc(ev.datum)} / Stunde ${esc(stunde)}
LV-Code${esc(ev.lv)}
Zeit${esc(ev.start.slice(11, 16))} - ${esc(ev.end.slice(11, 16))}
LektorIn${esc(rows["LektorIn"])}
LektorIn${lektorCell}
Ort${esc(rows["Ort"])}
Lehrfach${esc(rows["Lehrfach"])}
Bezeichnung${esc(rows["Bezeichnung"])}
{{ loop.index }}{{ st.nachname }}{{ st.vorname }}{{ st.nachname }} {{ st.vorname }}{{ st.geschlecht }} {% if dec %} diff --git a/app/templates/person.html b/app/templates/person.html index 91fbd45..0eb5caf 100644 --- a/app/templates/person.html +++ b/app/templates/person.html @@ -40,7 +40,7 @@
{% endif %}
- {% if uid.isdigit() %}LV-Plan anzeigen{% endif %} + LV-Plan anzeigen Zurück zur Fotowand