def get_subordinate_users(user, site):
 from cms.utils.page_permissions import get_change_permissions_id_list
 try:
  user_level = get_user_permission_level(user, site)
 except NoPermissionsException:
  qs = get_user_model().objects.distinct().filter(((Q(is_staff=True) & Q(pageuser__created_by=user)) & Q(pagepermission__page=None)))
  qs = qs.exclude(pk=user.pk).exclude(groups__user__pk=user.pk)
  return qs
 if (user_level == ROOT_USER_LEVEL):
  return get_user_model().objects.all()
 page_id_allow_list = get_change_permissions_id_list(user, site, check_global=False)
 qs = get_user_model().objects.distinct().filter(((Q(is_staff=True) & (Q(pagepermission__page__id__in=page_id_allow_list) & Q(pagepermission__page__depth__gte=user_level))) | (Q(pageuser__created_by=user) & Q(pagepermission__page=None))))
 qs = qs.exclude(pk=user.pk).exclude(groups__user__pk=user.pk)
 return qs

def get_subordinate_users ( user , site ) : from cms . utils . page_permissions import get_change_permissions_id_list try : user_level = get_user_permission_level ( user , site ) except NoPermissionsException : qs = get_user_model ( ) . objects . distinct ( ) . filter ( ( ( Q ( is_staff = True ) & Q ( pageuser__created_by = user ) ) & Q ( pagepermission__page = None ) ) ) qs = qs . exclude ( pk = user . pk ) . exclude ( groups__user__pk = user . pk ) return qs if ( user_level == ROOT_USER_LEVEL ) : return get_user_model ( ) . objects . all ( ) page_id_allow_list = get_change_permissions_id_list ( user , site , check_global = False ) qs = get_user_model ( ) . objects . distinct ( ) . filter ( ( ( Q ( is_staff = True ) & ( Q ( pagepermission__page__id__in = page_id_allow_list ) & Q ( pagepermission__page__depth__gte = user_level ) ) ) | ( Q ( pageuser__created_by = user ) & Q ( pagepermission__page = None ) ) ) ) qs = qs . exclude ( pk = user . pk ) . exclude ( groups__user__pk = user . pk ) return qs
returns users queryset .