From acfb633cda01002590203b2390f221dcb7c4f9b7 Mon Sep 17 00:00:00 2001 From: AIIrondev Date: Mon, 14 Sep 2026 09:40:59 +0200 Subject: [PATCH] changes to the Scanning processing --- Web/app.py | 8 ++++++++ Web/templates/library_table.html | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Web/app.py b/Web/app.py index 7753607..24a7ba7 100755 --- a/Web/app.py +++ b/Web/app.py @@ -4276,6 +4276,7 @@ def api_library_scan_action(): - scan student card id - scan media code (ISBN/Code_4) - borrow if available, otherwise return (toggle behavior) + - action='borrow' can be used by scan modes that must never return an item """ if 'username' not in session: return jsonify({'ok': False, 'message': 'Nicht angemeldet.'}), 401 @@ -4285,6 +4286,7 @@ def api_library_scan_action(): return jsonify({'ok': False, 'message': 'Schülerausweis-Modul ist deaktiviert.'}), 403 payload = request.get_json(silent=True) or {} + requested_action = str(payload.get('action') or 'toggle').strip().lower() student_card_id = us.normalize_student_card_id(payload.get('student_card_id') or payload.get('card_id')) item_code_raw = str(payload.get('item_code') or payload.get('code') or '').strip() duration_raw = str(payload.get('borrow_duration_days') or '').strip() @@ -4388,6 +4390,12 @@ def api_library_scan_action(): 'message': f"{item_doc.get('Name', 'Medium')} wurde ausgeliehen." }), 200 + if requested_action == 'borrow': + return jsonify({ + 'ok': False, + 'message': f"Medium ist bereits ausgeliehen und wurde nicht verändert.", + }), 409 + # Toggle back: item is currently borrowed -> return current_borrower = str(item_doc.get('User') or '').strip() current_permissions = us.get_effective_permissions(session['username']) diff --git a/Web/templates/library_table.html b/Web/templates/library_table.html index 56fc5bb..953d3f0 100644 --- a/Web/templates/library_table.html +++ b/Web/templates/library_table.html @@ -1414,7 +1414,8 @@ }, body: JSON.stringify({ student_card_id: activeStudentCardId, - item_code: scannedCode + item_code: scannedCode, + action: 'borrow' }) });