from django.shortcuts import render from django.contrib.auth.decorators import login_required @login_required def dashboard(request): user = request.user # 1️⃣ Superuser / Owner if user.is_superuser or (hasattr(user, 'userprofile') and user.userprofile.role == 'owner'): return render(request, 'core/dashboard/owner.html', {'user': user}) # 2️⃣ Psychologist elif hasattr(user, 'userprofile') and user.userprofile.role == 'psychologist': return render(request, 'core/dashboard/psychologist.html', {'user': user}) # 3️⃣ Client elif hasattr(user, 'userprofile') and user.userprofile.role == 'client': return render(request, 'core/dashboard/client.html', {'user': user}) # 4️⃣ Default (jaga-jaga) # fallback: use the owner dashboard template under core/dashboard/ to match existing files return render(request, 'core/dashboard/owner.html', {'user': user})