🐛 Backend Database Improvement: Added shm and wal files for myp.db & updated debug_guest_requests.py & admin_guest_requests_overview.html 🎉
This commit is contained in:
parent
a5ce18eeee
commit
ef5f56063e
Binary file not shown.
BIN
backend/app/database/myp.db-shm
Normal file
BIN
backend/app/database/myp.db-shm
Normal file
Binary file not shown.
BIN
backend/app/database/myp.db-wal
Normal file
BIN
backend/app/database/myp.db-wal
Normal file
Binary file not shown.
@ -1 +1,80 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Debug-Script für Gastanträge und Admin-Berechtigungen
|
||||
"""
|
||||
|
||||
from models import get_cached_session, GuestRequest, User, UserPermission
|
||||
from flask_login import current_user
|
||||
|
||||
def check_guest_requests():
|
||||
"""Prüfe Gastanträge nach Status"""
|
||||
print("=== GASTANTRÄGE STATUS ===")
|
||||
|
||||
with get_cached_session() as db:
|
||||
pending = db.query(GuestRequest).filter_by(status='pending').count()
|
||||
approved = db.query(GuestRequest).filter_by(status='approved').count()
|
||||
rejected = db.query(GuestRequest).filter_by(status='rejected').count()
|
||||
total = db.query(GuestRequest).count()
|
||||
|
||||
print(f"Gesamt: {total}")
|
||||
print(f"Pending (Wird geprüft): {pending}")
|
||||
print(f"Approved (Genehmigt): {approved}")
|
||||
print(f"Rejected (Abgelehnt): {rejected}")
|
||||
|
||||
if pending == 0:
|
||||
print("\n⚠️ PROBLEM: Keine Anträge mit Status 'pending' gefunden!")
|
||||
print(" → Die Genehmigen/Ablehnen-Buttons werden nur bei Status 'pending' angezeigt")
|
||||
|
||||
# Erstelle einen Test-Antrag
|
||||
print("\n🔧 Erstelle Test-Gastantrag...")
|
||||
test_request = GuestRequest(
|
||||
name="Test Admin",
|
||||
email="admin@test.de",
|
||||
reason="Test für Admin-Buttons",
|
||||
duration_min=30,
|
||||
status="pending"
|
||||
)
|
||||
db.add(test_request)
|
||||
db.commit()
|
||||
print(f"✅ Test-Antrag erstellt (ID: {test_request.id})")
|
||||
else:
|
||||
print(f"\n✅ {pending} Anträge mit Status 'pending' gefunden")
|
||||
|
||||
# Zeige pending Anträge
|
||||
pending_requests = db.query(GuestRequest).filter_by(status='pending').all()
|
||||
for req in pending_requests:
|
||||
print(f" ID {req.id}: {req.name} - {req.email}")
|
||||
|
||||
def check_admin_users():
|
||||
"""Prüfe Admin-Benutzer und Berechtigungen"""
|
||||
print("\n=== ADMIN-BENUTZER ===")
|
||||
|
||||
with get_cached_session() as db:
|
||||
# Alle Admins
|
||||
admins = db.query(User).filter_by(is_admin=True).all()
|
||||
print(f"Admin-Benutzer: {len(admins)}")
|
||||
for admin in admins:
|
||||
print(f" {admin.username} (ID: {admin.id}) - Email: {admin.email}")
|
||||
|
||||
# Benutzer mit can_approve_jobs
|
||||
users_with_approval = db.query(User).join(UserPermission).filter(
|
||||
UserPermission.can_approve_jobs == True
|
||||
).all()
|
||||
print(f"\nBenutzer mit can_approve_jobs: {len(users_with_approval)}")
|
||||
for user in users_with_approval:
|
||||
print(f" {user.username} (ID: {user.id}) - Email: {user.email}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
check_guest_requests()
|
||||
check_admin_users()
|
||||
print("\n=== LÖSUNG ===")
|
||||
print("1. Gehen Sie zu: http://127.0.0.1:5000/requests/overview")
|
||||
print("2. Öffnen Sie die Browser-Konsole (F12)")
|
||||
print("3. Suchen Sie nach 'Admin-Berechtigungen:' in der Konsole")
|
||||
print("4. Die Buttons sollten bei Anträgen mit Status 'pending' erscheinen")
|
||||
|
||||
except Exception as e:
|
||||
print(f"❌ Fehler: {e}")
|
||||
import traceback
|
||||
traceback.print_exc()
|
@ -572,10 +572,26 @@ const userIsAdmin = adminConfig.dataset.isAdmin === 'true';
|
||||
const userCanApprove = adminConfig.dataset.canApprove === 'true';
|
||||
const showInlineActions = userIsAdmin || userCanApprove;
|
||||
|
||||
console.log('Admin-Berechtigungen:', { userIsAdmin, userCanApprove, showInlineActions });
|
||||
console.log('🔍 DEBUG: Admin-Berechtigungen:', {
|
||||
userIsAdmin,
|
||||
userCanApprove,
|
||||
showInlineActions,
|
||||
adminConfigElement: adminConfig,
|
||||
dataIsAdmin: adminConfig.dataset.isAdmin,
|
||||
dataCanApprove: adminConfig.dataset.canApprove
|
||||
});
|
||||
|
||||
// Debug: Zeige alle Data-Attribute
|
||||
console.log('🔍 DEBUG: Alle Data-Attribute:', adminConfig.dataset);
|
||||
|
||||
// Debug: Prüfe HTML-Inhalt
|
||||
console.log('🔍 DEBUG: AdminConfig HTML:', adminConfig.outerHTML);
|
||||
|
||||
// Initialisierung
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
console.log('🚀 DEBUG: DOMContentLoaded - Initialisierung startet');
|
||||
console.log('🔍 DEBUG: showInlineActions beim Laden:', showInlineActions);
|
||||
|
||||
initializeEventListeners();
|
||||
loadAvailablePrinters();
|
||||
loadGuestRequests();
|
||||
@ -764,37 +780,22 @@ function createRequestRow(request) {
|
||||
const hoursOld = (now - createdAt) / (1000 * 60 * 60);
|
||||
const isUrgent = hoursOld > 24 && request.status === 'pending';
|
||||
|
||||
// DEBUG: Zeige Request-Details
|
||||
console.log('🔍 DEBUG: createRequestRow für Request:', {
|
||||
id: request.id,
|
||||
name: request.name,
|
||||
status: request.status,
|
||||
isPending: request.status === 'pending',
|
||||
showInlineActions: showInlineActions,
|
||||
shouldShowButtons: request.status === 'pending' && showInlineActions
|
||||
});
|
||||
|
||||
if (isUrgent) {
|
||||
row.classList.add('urgent-request');
|
||||
}
|
||||
|
||||
row.innerHTML = `
|
||||
<td class="px-6 py-4 whitespace-nowrap">
|
||||
<div class="flex items-center">
|
||||
<div>
|
||||
<div class="text-sm font-medium text-gray-900">
|
||||
${escapeHtml(request.name)}
|
||||
${isUrgent ? '<span class="ml-2 inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-red-100 text-red-800"><i class="fas fa-exclamation-triangle mr-1"></i>Dringend</span>' : ''}
|
||||
</div>
|
||||
<div class="text-sm text-gray-500">${escapeHtml(request.email || 'Keine E-Mail')}</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap">
|
||||
<div class="text-sm text-gray-900">
|
||||
<i class="fas fa-file mr-1"></i>${escapeHtml(request.file_name || 'Keine Datei')}
|
||||
</div>
|
||||
<div class="text-sm text-gray-500">
|
||||
<i class="fas fa-clock mr-1"></i>${request.duration_minutes || 0} Min,
|
||||
<i class="fas fa-copy ml-2 mr-1"></i>${request.copies || 1} Kopien
|
||||
</div>
|
||||
${request.reason ? `<div class="text-xs text-gray-400 mt-1">${escapeHtml(request.reason.substring(0, 100))}${request.reason.length > 100 ? '...' : ''}</div>` : ''}
|
||||
</td>
|
||||
<td class="px-6 py-4">
|
||||
<span class="status-badge status-${request.status}">
|
||||
${getStatusIcon(request.status)} ${getStatusText(request.status)}
|
||||
</span>
|
||||
${request.status === 'pending' && showInlineActions ? `
|
||||
// DEBUG: Button-HTML generieren
|
||||
const buttonHtml = request.status === 'pending' && showInlineActions ? `
|
||||
<div id="inline-actions-${request.id}" class="mt-2 space-y-2">
|
||||
<div class="flex space-x-2">
|
||||
<button onclick="showInlineApproval(${request.id})"
|
||||
@ -851,7 +852,37 @@ function createRequestRow(request) {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
` : ''}
|
||||
` : '';
|
||||
|
||||
console.log('🔍 DEBUG: Button-HTML für Request', request.id, ':', buttonHtml ? 'GENERIERT' : 'LEER');
|
||||
|
||||
row.innerHTML = `
|
||||
<td class="px-6 py-4 whitespace-nowrap">
|
||||
<div class="flex items-center">
|
||||
<div>
|
||||
<div class="text-sm font-medium text-gray-900">
|
||||
${escapeHtml(request.name)}
|
||||
${isUrgent ? '<span class="ml-2 inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-red-100 text-red-800"><i class="fas fa-exclamation-triangle mr-1"></i>Dringend</span>' : ''}
|
||||
</div>
|
||||
<div class="text-sm text-gray-500">${escapeHtml(request.email || 'Keine E-Mail')}</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap">
|
||||
<div class="text-sm text-gray-900">
|
||||
<i class="fas fa-file mr-1"></i>${escapeHtml(request.file_name || 'Keine Datei')}
|
||||
</div>
|
||||
<div class="text-sm text-gray-500">
|
||||
<i class="fas fa-clock mr-1"></i>${request.duration_minutes || 0} Min,
|
||||
<i class="fas fa-copy ml-2 mr-1"></i>${request.copies || 1} Kopien
|
||||
</div>
|
||||
${request.reason ? `<div class="text-xs text-gray-400 mt-1">${escapeHtml(request.reason.substring(0, 100))}${request.reason.length > 100 ? '...' : ''}</div>` : ''}
|
||||
</td>
|
||||
<td class="px-6 py-4">
|
||||
<span class="status-badge status-${request.status}">
|
||||
${getStatusIcon(request.status)} ${getStatusText(request.status)}
|
||||
</span>
|
||||
${buttonHtml}
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
|
||||
<div>${formatDate(request.created_at)}</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user