changes for the loading of the recent borrowers that only the latest 3 get displayed

This commit is contained in:
2026-07-27 14:34:59 +02:00
parent feac00f0df
commit 06486f039f
+19 -18
View File
@@ -3605,24 +3605,25 @@ def api_item_detail(item_id):
borrows_html = '' borrows_html = ''
if borrow_records: if borrow_records:
rows = [] rows = []
for rec in borrow_records: while len(rows) < 3:
user_raw = rec.get('User') for rec in borrow_records:
try: user_raw = rec.get('User')
user = decrypt_text(user_raw) if user_raw is not None else '' try:
except Exception: user = decrypt_text(user_raw) if user_raw is not None else ''
user = user_raw except Exception:
status = rec.get('Status', '') user = user_raw
start = fmt_dt(rec.get('Start')) status = rec.get('Status', '')
end = fmt_dt(rec.get('End')) start = fmt_dt(rec.get('Start'))
notes = html.escape(str(rec.get('Notes') or '')) end = fmt_dt(rec.get('End'))
notes = html.escape(str(rec.get('Notes') or ''))
rows.append(
f"<li><strong>{html.escape(str(user or '-'))}</strong> — " rows.append(
f"{html.escape(str(status))}" f"<li><strong>{html.escape(str(user or '-'))}</strong>"
f"{html.escape(str(start))} {html.escape(str(end))}" f"{html.escape(str(status))} "
f"{('' + notes) if notes else ''}</li>" f"{html.escape(str(start))}{html.escape(str(end))}"
) f"{('' + notes) if notes else ''}</li>"
borrows_html = f"<h3>Ausleihhistorie</h3><ul>{''.join(rows)}</ul>" )
borrows_html = f"<h3>Ausleihhistorie</h3><ul>{''.join(rows)}</ul>"
detail_html = f""" detail_html = f"""
<h2>{html.escape(str(item.get('Name', 'Untitled')))}</h2> <h2>{html.escape(str(item.get('Name', 'Untitled')))}</h2>