"""
Quick test to check URL generation
"""
import os, sys, django
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'branch_system.settings')
django.setup()

from django.urls import reverse, resolve
from users.models import CustomUser

# Get a test user
user = CustomUser.objects.filter(is_staff=True).first()
if user:
    url = reverse('users:simplified_user_permissions', args=[str(user.id)])
    print(f"Generated URL: {url}")
    
    # Test resolution
    resolved = resolve(url)
    print(f"Resolves to: {resolved.func.__name__}")
    print(f"View module: {resolved.func.__module__}")
    
    # Check if it matches admin_detail
    from users.views import admin_detail
    if resolved.func == admin_detail:
        print("ERROR: URL resolves to admin_detail instead of simplified_user_permissions!")
    else:
        print("OK: URL resolves to correct view")
else:
    print("No staff users found")

