Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f9b991d991 | |||
| 363f0df530 | |||
| 34bb3cf4c3 | |||
| 18706c6d1c | |||
| 9771b98075 | |||
| e380ad6092 | |||
| d6e8e08b10 | |||
| ddb6ab82ad | |||
| baefc55257 | |||
| 6c359089cd | |||
| 479cf3d98c | |||
| f00e7d8f74 | |||
| 7af729ac88 | |||
| 847349b419 | |||
| 91a80c6330 |
+24
-14
@@ -4349,10 +4349,14 @@ def api_library_scan_action():
|
||||
|
||||
due_date = now + datetime.timedelta(days=borrow_duration_days)
|
||||
|
||||
it.update_item_status(item_id, False, borrower_name)
|
||||
app.logger.info(f"Library scan action: borrowing item {item_id} for student card {student_card_id} until {due_date.isoformat()}")
|
||||
borrower_user = us.get_user_by_student_card(student_card_id)
|
||||
app.logger.info(f"Found borrower user: {borrower_user}")
|
||||
if not borrower_user or not borrower_user.get('_id'):
|
||||
app.logger.warning(f"No user found for student card {student_card_id}. Cannot record borrowing in ausleihungen.")
|
||||
return jsonify({'ok': False, 'message': 'Kein Benutzer für diesen Schülerausweis gefunden.'}), 404
|
||||
|
||||
it.update_item_status(item_id, False, borrower_name)
|
||||
au.add_ausleihung(
|
||||
item_id,
|
||||
str(borrower_user['_id']),
|
||||
@@ -4367,7 +4371,7 @@ def api_library_scan_action():
|
||||
'channel': 'library_scan',
|
||||
'item_id': item_id,
|
||||
'item_name': item_doc.get('Name', ''),
|
||||
'borrower':borrower_name,
|
||||
'borrower': borrower_name,
|
||||
'student_card_id': student_card_id,
|
||||
'borrow_duration_days': borrow_duration_days,
|
||||
}
|
||||
@@ -4457,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')))
|
||||
@@ -4493,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'):
|
||||
@@ -4525,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>"
|
||||
|
||||
@@ -697,7 +697,7 @@ def get_user_by_student_card(student_card_id):
|
||||
client = MongoClient(cfg.MONGODB_HOST, cfg.MONGODB_PORT)
|
||||
db = _get_tenant_db(client)
|
||||
users = db['student_cards']
|
||||
found_user = users.find_one({'SchülerName': normalized})
|
||||
found_user = users.find_one({'AusweisId': normalized})
|
||||
client.close()
|
||||
|
||||
# Do not call dp.decrypt_text() here because found_user is a MongoDB dictionary.
|
||||
|
||||
@@ -266,6 +266,11 @@
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.code-search-label {
|
||||
color: #b93845;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.search-button {
|
||||
padding: 8px 12px;
|
||||
background-color: #007bff;
|
||||
@@ -284,10 +289,10 @@
|
||||
}
|
||||
|
||||
#code-search.searching {
|
||||
background-color: #fff3cd;
|
||||
background-color: #fff5f5;
|
||||
transition: background-color 0.3s;
|
||||
border: 2px solid #ffc107;
|
||||
box-shadow: 0 0 8px rgba(255, 193, 7, 0.5);
|
||||
border: 2px solid #d65a62;
|
||||
box-shadow: 0 0 8px rgba(190, 55, 66, 0.28);
|
||||
}
|
||||
|
||||
/* QR Scanner styles */
|
||||
@@ -562,32 +567,55 @@
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.navigation-buttons {
|
||||
display: contents;
|
||||
}
|
||||
|
||||
.items-navigation {
|
||||
display: grid;
|
||||
grid-template-columns: auto minmax(0, 1fr) auto;
|
||||
grid-template-columns: 42px minmax(0, 1fr) 42px;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
column-gap: 16px;
|
||||
width: calc(100% + 116px);
|
||||
margin-left: -58px;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.navigation-buttons .prev-button,
|
||||
.navigation-buttons .next-button {
|
||||
background-color: #007bff;
|
||||
color: #fff;
|
||||
border: none;
|
||||
.navigation-button-slot {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.navigation-button {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 42px;
|
||||
height: 42px;
|
||||
padding: 0;
|
||||
background: var(--ui-surface-soft);
|
||||
color: var(--ui-title);
|
||||
border: 1px solid var(--ui-border);
|
||||
box-shadow: var(--ui-shadow-sm);
|
||||
cursor: pointer;
|
||||
padding: 10px;
|
||||
border-radius: 5px;
|
||||
border-radius: 10px;
|
||||
font-size: 1.15rem;
|
||||
font-weight: 700;
|
||||
line-height: 1;
|
||||
transition: transform 160ms ease, box-shadow 160ms ease, background-color 160ms ease, border-color 160ms ease;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.navigation-buttons .prev-button:hover,
|
||||
.navigation-buttons .next-button:hover {
|
||||
background-color: #0056b3;
|
||||
.navigation-button:hover {
|
||||
background: var(--ui-surface);
|
||||
border-color: var(--module-accent-color);
|
||||
box-shadow: var(--ui-shadow-md);
|
||||
transform: translateY(-2px) scale(1.04);
|
||||
}
|
||||
|
||||
.navigation-button:active {
|
||||
transform: translateY(0) scale(0.96);
|
||||
}
|
||||
|
||||
.navigation-button:focus-visible {
|
||||
outline: 3px solid rgba(37, 99, 235, 0.35);
|
||||
outline-offset: 3px;
|
||||
}
|
||||
|
||||
/* Modal styles */
|
||||
@@ -750,15 +778,15 @@
|
||||
}
|
||||
|
||||
.code-match {
|
||||
border: 2px solid #17a2b8 !important;
|
||||
box-shadow: 0 0 15px rgba(23, 162, 184, 0.5) !important;
|
||||
border: 2px solid #d65a62 !important;
|
||||
box-shadow: 0 0 15px rgba(190, 55, 66, 0.28) !important;
|
||||
position: relative;
|
||||
z-index: 5;
|
||||
}
|
||||
|
||||
.exact-code-match {
|
||||
border: 3px solid #28a745 !important;
|
||||
box-shadow: 0 0 20px rgba(40, 167, 69, 0.7) !important;
|
||||
border: 3px solid #b93845 !important;
|
||||
box-shadow: 0 0 20px rgba(185, 56, 69, 0.42) !important;
|
||||
position: relative;
|
||||
z-index: 11;
|
||||
}
|
||||
@@ -1641,9 +1669,11 @@
|
||||
/* Navigation buttons mobile */
|
||||
.items-navigation {
|
||||
display: block !important;
|
||||
width: 100% !important;
|
||||
margin-left: 0 !important;
|
||||
}
|
||||
|
||||
.navigation-buttons {
|
||||
.navigation-button-slot {
|
||||
display: none !important; /* Hide horizontal navigation on mobile */
|
||||
}
|
||||
|
||||
@@ -1956,7 +1986,7 @@
|
||||
/* Standardized button styles across the application */
|
||||
.search-button, .scan-button, .filter-toggle, .clear-filter,
|
||||
.add-new-btn, .popup-close-button, .prev-image-button, .next-image-button,
|
||||
.navigation-buttons .prev-button, .navigation-buttons .next-button {
|
||||
.navigation-button {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
@@ -2511,7 +2541,7 @@ document.addEventListener('DOMContentLoaded', ()=>{
|
||||
|
||||
<div class="filter-group search-field">
|
||||
<div class="filter-header">
|
||||
<label for="code-search">Code suchen:</label>
|
||||
<label class="code-search-label" for="code-search">Code suchen:</label>
|
||||
<button type="button" class="clear-filter" onclick="clearCodeSearch()">Clear</button>
|
||||
</div>
|
||||
<div class="search-container">
|
||||
@@ -2554,13 +2584,15 @@ document.addEventListener('DOMContentLoaded', ()=>{
|
||||
</div>
|
||||
|
||||
<div class="items-navigation">
|
||||
<div class="navigation-buttons">
|
||||
<button class="prev-button" type="button" onclick="scrollPrev()" aria-label="Vorherige Elemente">❮</button>
|
||||
<button class="next-button" type="button" onclick="scrollNext()" aria-label="Nächste Elemente">❯</button>
|
||||
<div class="navigation-button-slot">
|
||||
<button class="navigation-button prev-button" type="button" onclick="scrollPrev()" aria-label="Vorherige Elemente">❮</button>
|
||||
</div>
|
||||
<div id="items-container" class="items-container">
|
||||
<!-- Items will be dynamically loaded here -->
|
||||
</div>
|
||||
<div class="navigation-button-slot">
|
||||
<button class="navigation-button next-button" type="button" onclick="scrollNext()" aria-label="Nächste Elemente">❯</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="item-modal" class="item-modal">
|
||||
@@ -3336,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');
|
||||
@@ -3358,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