changes to the Scanning processing
Release Inventarsystem / release-docker (push) Successful in 2m27s
Release Inventarsystem / release-docker (push) Successful in 2m27s
This commit is contained in:
@@ -4276,6 +4276,7 @@ def api_library_scan_action():
|
|||||||
- scan student card id
|
- scan student card id
|
||||||
- scan media code (ISBN/Code_4)
|
- scan media code (ISBN/Code_4)
|
||||||
- borrow if available, otherwise return (toggle behavior)
|
- 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:
|
if 'username' not in session:
|
||||||
return jsonify({'ok': False, 'message': 'Nicht angemeldet.'}), 401
|
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
|
return jsonify({'ok': False, 'message': 'Schülerausweis-Modul ist deaktiviert.'}), 403
|
||||||
|
|
||||||
payload = request.get_json(silent=True) or {}
|
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'))
|
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()
|
item_code_raw = str(payload.get('item_code') or payload.get('code') or '').strip()
|
||||||
duration_raw = str(payload.get('borrow_duration_days') 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."
|
'message': f"{item_doc.get('Name', 'Medium')} wurde ausgeliehen."
|
||||||
}), 200
|
}), 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
|
# Toggle back: item is currently borrowed -> return
|
||||||
current_borrower = str(item_doc.get('User') or '').strip()
|
current_borrower = str(item_doc.get('User') or '').strip()
|
||||||
current_permissions = us.get_effective_permissions(session['username'])
|
current_permissions = us.get_effective_permissions(session['username'])
|
||||||
|
|||||||
@@ -1414,7 +1414,8 @@
|
|||||||
},
|
},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
student_card_id: activeStudentCardId,
|
student_card_id: activeStudentCardId,
|
||||||
item_code: scannedCode
|
item_code: scannedCode,
|
||||||
|
action: 'borrow'
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user