🎉 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:
79
backend/quick_admin_test.py
Normal file
79
backend/quick_admin_test.py
Normal file
@ -0,0 +1,79 @@
|
||||
#!/usr/bin/env python3.11
|
||||
"""
|
||||
Schneller Test für das Admin-Dashboard ohne Server
|
||||
"""
|
||||
|
||||
from app import app
|
||||
from models import User, get_cached_session
|
||||
from flask_login import login_user
|
||||
|
||||
def test_admin_dashboard_direct():
|
||||
"""Testet das Admin-Dashboard direkt"""
|
||||
|
||||
print("=== DIREKTER ADMIN DASHBOARD TEST ===")
|
||||
|
||||
with app.app_context():
|
||||
try:
|
||||
# Admin-Benutzer finden
|
||||
with get_cached_session() as session:
|
||||
admin_user = session.query(User).filter(User.role == 'admin').first()
|
||||
|
||||
if not admin_user:
|
||||
print("❌ Kein Admin-Benutzer gefunden!")
|
||||
return False
|
||||
|
||||
print(f"✅ Admin-Benutzer gefunden: {admin_user.username}")
|
||||
|
||||
# Test mit simuliertem Login
|
||||
with app.test_client() as client:
|
||||
with client.session_transaction() as sess:
|
||||
sess['_user_id'] = str(admin_user.id)
|
||||
sess['_fresh'] = True
|
||||
|
||||
# Admin-Dashboard aufrufen
|
||||
response = client.get('/admin/')
|
||||
print(f"Status: {response.status_code}")
|
||||
|
||||
if response.status_code == 200:
|
||||
print("✅ SUCCESS: Admin-Dashboard lädt erfolgreich!")
|
||||
print(f"Content-Length: {len(response.get_data())} Bytes")
|
||||
|
||||
# Prüfe, ob wichtige Inhalte vorhanden sind
|
||||
content = response.get_data(as_text=True)
|
||||
if "Admin-Dashboard" in content:
|
||||
print("✅ Dashboard-Titel gefunden")
|
||||
if "Benutzerverwaltung" in content:
|
||||
print("✅ Benutzer-Tab gefunden")
|
||||
if "Drucker-Steckdosen" in content:
|
||||
print("✅ Drucker-Tab gefunden")
|
||||
|
||||
return True
|
||||
|
||||
elif response.status_code == 302:
|
||||
print(f"❌ Redirect zu: {response.headers.get('Location', 'Unknown')}")
|
||||
return False
|
||||
|
||||
elif response.status_code == 500:
|
||||
print("❌ 500 Internal Server Error")
|
||||
error_data = response.get_data(as_text=True)
|
||||
print(f"Error: {error_data[:500]}...")
|
||||
return False
|
||||
|
||||
else:
|
||||
print(f"❌ Unerwarteter Status: {response.status_code}")
|
||||
return False
|
||||
|
||||
except Exception as e:
|
||||
print(f"❌ FEHLER: {e}")
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
return False
|
||||
|
||||
if __name__ == "__main__":
|
||||
success = test_admin_dashboard_direct()
|
||||
if success:
|
||||
print("\n🎉 ADMIN-DASHBOARD FUNKTIONIERT!")
|
||||
else:
|
||||
print("\n❌ ADMIN-DASHBOARD HAT PROBLEME!")
|
||||
|
||||
exit(0 if success else 1)
|
Reference in New Issue
Block a user