def moderation_access(request):
    """Add moderation access check to template context"""
    context = {
        "has_moderation_access": False,
        "has_admin_access": False,
        "has_superuser_access": False,
        "user_role": None,
    }

    if request.user.is_authenticated:
        context["user_role"] = request.user.role
        # Check both role-based and Django's built-in superuser status
        context["has_moderation_access"] = (
            request.user.role in ["MODERATOR", "ADMIN", "SUPERUSER"] or request.user.is_superuser
        )
        context["has_admin_access"] = request.user.role in ["ADMIN", "SUPERUSER"] or request.user.is_superuser
        context["has_superuser_access"] = request.user.role == "SUPERUSER" or request.user.is_superuser

    return context
