Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f9b991d991 | |||
| 363f0df530 | |||
| 34bb3cf4c3 | |||
| 18706c6d1c | |||
| 9771b98075 | |||
| e380ad6092 | |||
| d6e8e08b10 | |||
| ddb6ab82ad |
+18
-12
@@ -4461,6 +4461,7 @@ def api_item_detail(item_id):
|
||||
db = client[MONGODB_DB]
|
||||
ausleihungen_col = db['ausleihungen']
|
||||
items_col = db['items']
|
||||
student_cards_col = db['student_cards']
|
||||
|
||||
# Determine parent/group id (if this is a child, use its ParentItemId)
|
||||
parent_id = str(item.get('ParentItemId') or str(item.get('_id')))
|
||||
@@ -4497,16 +4498,25 @@ def api_item_detail(item_id):
|
||||
else:
|
||||
status_label = 'Verfügbar'
|
||||
|
||||
# Helper function to get borrower display name
|
||||
def get_borrower_name(user_raw):
|
||||
if not user_raw:
|
||||
return ''
|
||||
try:
|
||||
user_doc = student_cards_col.find_one({'_id': ObjectId(user_raw)})
|
||||
if user_doc:
|
||||
if user_doc.get('SchülerName'):
|
||||
return decrypt_text(str(user_doc.get('SchülerName', '')))
|
||||
return str(user_doc.get('AusweisId', ''))
|
||||
except Exception:
|
||||
pass
|
||||
return str(user_raw)
|
||||
|
||||
# Prefer the most recent active borrower across the group
|
||||
borrower_value = ''
|
||||
for rec in borrow_records:
|
||||
if rec.get('Status') == 'active' and rec.get('User'):
|
||||
try:
|
||||
user_raw = rec.get('User')
|
||||
if user_raw is not None:
|
||||
borrower_value = decrypt_text(str(user_raw))
|
||||
except Exception:
|
||||
borrower_value = str(rec.get('User', ''))
|
||||
borrower_value = get_borrower_name(rec.get('User'))
|
||||
break
|
||||
|
||||
if not borrower_value and item.get('User'):
|
||||
@@ -4529,17 +4539,13 @@ def api_item_detail(item_id):
|
||||
rows = []
|
||||
|
||||
for rec in borrow_records[:3]:
|
||||
user_raw = rec.get('User')
|
||||
try:
|
||||
user = decrypt_text(user_raw) if user_raw is not None else ''
|
||||
except Exception:
|
||||
user = user_raw
|
||||
rec_borrower_name = get_borrower_name(rec.get('User')) or '-'
|
||||
status = rec.get('Status', '')
|
||||
start = fmt_dt(rec.get('Start'))
|
||||
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> — "
|
||||
f"<li><strong>{html.escape(rec_borrower_name)}</strong> — "
|
||||
f"{html.escape(str(status))} — "
|
||||
f"{html.escape(str(start))} → {html.escape(str(end))}"
|
||||
f"{(' — ' + notes) if notes else ''}</li>"
|
||||
|
||||
@@ -3368,10 +3368,11 @@ document.addEventListener('DOMContentLoaded', ()=>{
|
||||
|
||||
function loadItems(offset = 0, append = false, searchTerm = '', searchScope = 'all') {
|
||||
// Keep list payload lightweight; full details are fetched on-demand in openItemQuick.
|
||||
const searchParams = searchTerm
|
||||
const searchParams = searchTerm && searchScope === 'title_description'
|
||||
? `&search=${encodeURIComponent(searchTerm)}&search_scope=${encodeURIComponent(searchScope)}`
|
||||
: '';
|
||||
return fetch(`{{ url_for('get_items') }}?offset=${offset}&limit=${MAIN_ADMIN_ITEMS_PAGE_SIZE}&light_mode=true${searchParams}`)
|
||||
const limit = (searchTerm && searchScope === 'all') ? 5000 : MAIN_ADMIN_ITEMS_PAGE_SIZE;
|
||||
return fetch(`{{ url_for('get_items') }}?offset=${offset}&limit=${limit}&light_mode=true${searchParams}`)
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
const itemsContainer = document.querySelector('#items-container');
|
||||
@@ -3390,8 +3391,7 @@ document.addEventListener('DOMContentLoaded', ()=>{
|
||||
if (!append && (!pageItems || pageItems.length === 0)) {
|
||||
itemsContainer.innerHTML = `
|
||||
<div class="no-items-message">
|
||||
<div>Keine Objekte gefunden</div>
|
||||
<a class="empty-state-cta" href="{{ url_for('upload_admin') }}">Erstellen sie hier ihr erstes Item</a>
|
||||
<div>Kein Item gefunden</div>
|
||||
</div>
|
||||
`;
|
||||
if (itemsIndicator) {
|
||||
|
||||
Reference in New Issue
Block a user