Profil-Verknuepfungen: Namensliste-Name und LektorIn in LV-Details linken direkt auf /person/<uid> (Name-to-Username-Lookup); Lektor-Profil bekommt LV-Plan-Button

This commit is contained in:
Nicolas Gruber
2026-10-21 14:08:42 +02:00
parent e5b01f7c6e
commit 5c4c4a2464
4 changed files with 29 additions and 3 deletions
+19 -1
View File
@@ -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)