from rest_framework import permissions class IsCRMAdmin(permissions.BasePermission): def has_permission(self, request, view): if not request.user or not request.user.is_authenticated: return False # Verify the user has an associated CRMAdmin profile return hasattr(request.user, 'crm_admin') and request.user.crm_admin.is_active