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:
+19
-1
@@ -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)
|
||||
|
||||
|
||||
+4
-1
@@ -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
|
||||
? `<a href="/person/${encodeURIComponent(j.lektor_uid)}" title="Profil anzeigen">${esc(rows["LektorIn"])}</a>`
|
||||
: esc(rows["LektorIn"])) : null;
|
||||
body.innerHTML = `
|
||||
<table>
|
||||
<tr><td>Datum / Stunde</td><td>${esc(ev.datum)} / Stunde ${esc(stunde)}</td></tr>
|
||||
<tr><td>LV-Code</td><td><b>${esc(ev.lv)}</b></td></tr>
|
||||
<tr><td>Zeit</td><td>${esc(ev.start.slice(11, 16))} - ${esc(ev.end.slice(11, 16))}</td></tr>
|
||||
${rows["LektorIn"] ? `<tr><td>LektorIn</td><td>${esc(rows["LektorIn"])}</td></tr>` : ""}
|
||||
${lektorCell ? `<tr><td>LektorIn</td><td>${lektorCell}</td></tr>` : ""}
|
||||
${rows["Ort"] ? `<tr><td>Ort</td><td>${esc(rows["Ort"])}</td></tr>` : ""}
|
||||
${rows["Lehrfach"] ? `<tr><td>Lehrfach</td><td>${esc(rows["Lehrfach"])}</td></tr>` : ""}
|
||||
${rows["Bezeichnung"] ? `<tr><td>Bezeichnung</td><td>${esc(rows["Bezeichnung"])}</td></tr>` : ""}
|
||||
|
||||
@@ -67,8 +67,13 @@
|
||||
{% set dec = decode_matrikel(st.matrikel, meta.stgs) %}
|
||||
<tr data-search="{{ (st.nachname ~ ' ' ~ st.vorname ~ ' ' ~ st.matrikel) | lower }}">
|
||||
<td class="num">{{ loop.index }}</td>
|
||||
{% if st.matrikel %}
|
||||
<td><a href="/person/{{ st.matrikel }}" title="Profil anzeigen">{{ st.nachname }}</a></td>
|
||||
<td><a href="/person/{{ st.matrikel }}" title="Profil anzeigen">{{ st.vorname }}</a></td>
|
||||
{% else %}
|
||||
<td>{{ st.nachname }}</td>
|
||||
<td>{{ st.vorname }}</td>
|
||||
{% endif %}
|
||||
<td>{{ st.geschlecht }}</td>
|
||||
<td class="mono">
|
||||
{% if dec %}
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
</table>
|
||||
{% endif %}
|
||||
<div class="person-actions">
|
||||
{% if uid.isdigit() %}<a class="btn btn-primary" href="/plan?uid={{ uid }}">LV-Plan anzeigen</a>{% endif %}
|
||||
<a class="btn btn-primary" href="/plan?uid={{ uid }}">LV-Plan anzeigen</a>
|
||||
<a class="btn" href="/fotos">Zurück zur Fotowand</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user