web: Sendungsliste neueste zuerst sortieren, Aufnahmen ohne Datum ganz unten
This commit is contained in:
@ -227,7 +227,19 @@ Deutschlandfunk Kultur): nach <a href="sendungen.html">Nummer</a>,
|
|||||||
return page("Start", body, "index")
|
return page("Start", body, "index")
|
||||||
|
|
||||||
|
|
||||||
|
def _datum_key(d):
|
||||||
|
"""'14.11.2026' -> (2026, 11, 14); '--.--.----' -> None."""
|
||||||
|
m = re.match(r"^(\d{2})\.(\d{2})\.(\d{4})$", d or "")
|
||||||
|
return (int(m.group(3)), int(m.group(2)), int(m.group(1))) if m else None
|
||||||
|
|
||||||
|
|
||||||
def build_sendungen(out, rows, abstracts):
|
def build_sendungen(out, rows, abstracts):
|
||||||
|
# neueste zuerst, Aufnahmen ohne Datum ganz unten
|
||||||
|
dated = [r for r in rows if _datum_key(r["datum"])]
|
||||||
|
undated = [r for r in rows if not _datum_key(r["datum"])]
|
||||||
|
dated.sort(key=lambda r: (_datum_key(r["datum"]), int(r["nr"])), reverse=True)
|
||||||
|
undated.sort(key=lambda r: int(r["nr"]), reverse=True)
|
||||||
|
rows = dated + undated
|
||||||
trs = []
|
trs = []
|
||||||
for r in rows:
|
for r in rows:
|
||||||
nr = r["nr"]
|
nr = r["nr"]
|
||||||
@ -242,6 +254,7 @@ def build_sendungen(out, rows, abstracts):
|
|||||||
f'<td class="ordner">{esc(r["ordner"])}</td></tr>')
|
f'<td class="ordner">{esc(r["ordner"])}</td></tr>')
|
||||||
body = f"""
|
body = f"""
|
||||||
<h1>Sendungsliste</h1>
|
<h1>Sendungsliste</h1>
|
||||||
|
<p class="ordner">neueste zuerst; Aufnahmen ohne Datum stehen ganz unten</p>
|
||||||
<table><thead><tr><th>Nr</th><th>Datum</th><th>Titel</th><th>Ordner</th></tr></thead>
|
<table><thead><tr><th>Nr</th><th>Datum</th><th>Titel</th><th>Ordner</th></tr></thead>
|
||||||
<tbody>{''.join(trs)}</tbody></table>"""
|
<tbody>{''.join(trs)}</tbody></table>"""
|
||||||
p = page("Sendungen", body, "sendungen")
|
p = page("Sendungen", body, "sendungen")
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user