🎉 Refactored backend structure: Removed unused files including app_cleaned.py, admin_api.py, admin.py, user.py, and others. Updated settings.local.json to include additional Bash commands. Enhanced admin templates for better navigation and functionality. Improved logging and error handling across various modules.

This commit is contained in:
2025-06-09 19:33:06 +02:00
parent 876b5a64e4
commit c7f9738bbe
115 changed files with 23507 additions and 9958 deletions

View File

@ -0,0 +1,62 @@
#!/usr/bin/env python3.11
"""
Skript zur automatischen Behebung von get_cached_session() Aufrufen
Konvertiert direkte Session-Aufrufe zu Context Manager Pattern.
Autor: MYP Team
Datum: 2025-06-09
"""
import re
import os
def fix_session_usage(file_path):
"""Behebt Session-Usage in einer Datei"""
with open(file_path, 'r', encoding='utf-8') as f:
content = f.read()
# Pattern für direkte Session-Aufrufe
patterns = [
# session = get_cached_session() -> with get_cached_session() as session:
(r'(\s+)session = get_cached_session\(\)', r'\1with get_cached_session() as session:'),
# session.close() entfernen (wird automatisch durch Context Manager gemacht)
(r'\s+session\.close\(\)\s*\n', '\n'),
# Einrückung nach with-Statement anpassen
(r'(with get_cached_session\(\) as session:\s*\n)(\s+)([^\s])',
lambda m: m.group(1) + m.group(2) + ' ' + m.group(3))
]
original_content = content
for pattern, replacement in patterns:
if callable(replacement):
content = re.sub(pattern, replacement, content, flags=re.MULTILINE)
else:
content = re.sub(pattern, replacement, content, flags=re.MULTILINE)
# Nur schreiben wenn sich etwas geändert hat
if content != original_content:
with open(file_path, 'w', encoding='utf-8') as f:
f.write(content)
print(f"{file_path} wurde aktualisiert")
return True
else:
print(f" {file_path} benötigt keine Änderungen")
return False
def main():
"""Hauptfunktion"""
backend_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
user_mgmt_file = os.path.join(backend_dir, 'blueprints', 'user_management.py')
if os.path.exists(user_mgmt_file):
print(f"Bearbeite {user_mgmt_file}...")
fix_session_usage(user_mgmt_file)
else:
print(f"❌ Datei nicht gefunden: {user_mgmt_file}")
if __name__ == "__main__":
main()