|
|
|
@@ -17,7 +17,6 @@ Features:
|
|
|
|
|
- Booking and reservation of items
|
|
|
|
|
"""
|
|
|
|
|
from random import random
|
|
|
|
|
|
|
|
|
|
from flask import Flask, render_template, request, redirect, url_for, session, flash, send_from_directory, get_flashed_messages, jsonify, Response, make_response, send_file, abort
|
|
|
|
|
from werkzeug.utils import secure_filename
|
|
|
|
|
from werkzeug.middleware.proxy_fix import ProxyFix
|
|
|
|
@@ -2189,7 +2188,7 @@ def _upload_student_cards_excel():
|
|
|
|
|
|
|
|
|
|
current_permissions = us.get_effective_permissions(session['username'])
|
|
|
|
|
|
|
|
|
|
if not current_permissions['actions'].get('can_manage_user', False):
|
|
|
|
|
if not current_permissions['actions'].get('can_manage_users', False):
|
|
|
|
|
flash('Ihnen fehlen die nötigen Berechtigungen, um diese Aktion auszuführen.', 'error')
|
|
|
|
|
return redirect(url_for('library_view'))
|
|
|
|
|
|
|
|
|
@@ -4277,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
|
|
|
|
@@ -4286,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()
|
|
|
|
@@ -4389,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'])
|
|
|
|
@@ -5162,7 +5169,6 @@ def student_card_class_barcode_download():
|
|
|
|
|
"""
|
|
|
|
|
Download PDF with student card barcodes filtered by a specific class from dropdown.
|
|
|
|
|
"""
|
|
|
|
|
from flask import request, session, redirect, url_for, send_file, flash
|
|
|
|
|
|
|
|
|
|
if 'username' not in session:
|
|
|
|
|
return redirect(url_for('login'))
|
|
|
|
@@ -5356,7 +5362,7 @@ def student_card_single_barcode_download(card_id):
|
|
|
|
|
return redirect(url_for('login'))
|
|
|
|
|
current_permissions = us.get_effective_permissions(session['username'])
|
|
|
|
|
|
|
|
|
|
if not current_permissions['actions'].get('can_manage_users', False):
|
|
|
|
|
if not current_permissions['actions'].get('can_manage_settings', False):
|
|
|
|
|
flash('Ihnen fehlen die nötigen Berechtigungen, um diese Aktion auszuführen.', 'error')
|
|
|
|
|
return redirect(url_for('library_view'))
|
|
|
|
|
if not cfg.MODULES.is_enabled('student_cards'):
|
|
|
|
|