changes to incorperate the Encryption frokm the borrower name correctly

This commit is contained in:
2026-07-19 20:20:41 +02:00
parent 0562aee04b
commit e1e488f723
+12 -8
View File
@@ -10404,13 +10404,8 @@ def admin_damaged_items():
flash('Administratorrechte erforderlich.', 'error') flash('Administratorrechte erforderlich.', 'error')
return redirect(url_for('login')) return redirect(url_for('login'))
''' # Import the decryption handler if it's not already at the top of the file
permissions = _get_current_user_permissions() from modules.inventarsystem.data_protection import decrypt_text
if not _action_access_allowed(permissions, 'can_manage_settings'):
flash('Sie haben keine Berechtigung, die Schulstammdaten zu ändern.', 'error')
if cfg.MODULES.is_enabled('library'):
return redirect(url_for('library_admin'))
'''
client = None client = None
try: try:
@@ -10450,9 +10445,18 @@ def admin_damaged_items():
{'Item': item_id, 'Status': {'$in': ['active', 'planned']}}, {'Item': item_id, 'Status': {'$in': ['active', 'planned']}},
{'_id': 1, 'User': 1, 'Status': 1, 'End': 1} {'_id': 1, 'User': 1, 'Status': 1, 'End': 1}
) )
# Decrypt the borrower inside the active loan tracking object
if active_borrow and active_borrow.get('User'):
active_borrow['User'] = decrypt_text(active_borrow['User'])
reports = item_doc.get('DamageReports', []) or [] reports = item_doc.get('DamageReports', []) or []
latest_report = reports[0] if reports else {} latest_report = reports[0] if reports else {}
# Decrypt the static snapshot borrower field on the item itself
raw_user = item_doc.get('User', '')
decrypted_user = decrypt_text(raw_user) if raw_user else ''
damaged_rows.append({ damaged_rows.append({
'id': item_id, 'id': item_id,
'name': item_doc.get('Name', ''), 'name': item_doc.get('Name', ''),
@@ -10462,7 +10466,7 @@ def admin_damaged_items():
'isbn': item_doc.get('ISBN', ''), 'isbn': item_doc.get('ISBN', ''),
'condition': item_doc.get('Condition', ''), 'condition': item_doc.get('Condition', ''),
'available': bool(item_doc.get('Verfuegbar', False)), 'available': bool(item_doc.get('Verfuegbar', False)),
'borrow_user': item_doc.get('User', ''), 'borrow_user': decrypted_user,
'damage_count': len(reports), 'damage_count': len(reports),
'damage_reports': reports, 'damage_reports': reports,
'latest_damage_description': latest_report.get('description', ''), 'latest_damage_description': latest_report.get('description', ''),