def get_subordinate_groups(user, site):
 from cms.utils.page_permissions import get_change_permissions_id_list
 try:
  user_level = get_user_permission_level(user, site)
 except NoPermissionsException:
  groups = Group.objects.filter((Q(pageusergroup__created_by=user) & Q(pagepermission__page__isnull=True))).distinct()
  return groups
 if (user_level == ROOT_USER_LEVEL):
  return Group.objects.all()
 page_id_allow_list = get_change_permissions_id_list(user, site, check_global=False)
 return Group.objects.distinct().filter(((Q(pagepermission__page__id__in=page_id_allow_list) & Q(pagepermission__page__depth__gte=user_level)) | (Q(pageusergroup__created_by=user) & Q(pagepermission__page__isnull=True))))

def get_subordinate_groups ( user , site ) : from cms . utils . page_permissions import get_change_permissions_id_list try : user_level = get_user_permission_level ( user , site ) except NoPermissionsException : groups = Group . objects . filter ( ( Q ( pageusergroup__created_by = user ) & Q ( pagepermission__page__isnull = True ) ) ) . distinct ( ) return groups if ( user_level == ROOT_USER_LEVEL ) : return Group . objects . all ( ) page_id_allow_list = get_change_permissions_id_list ( user , site , check_global = False ) return Group . objects . distinct ( ) . filter ( ( ( Q ( pagepermission__page__id__in = page_id_allow_list ) & Q ( pagepermission__page__depth__gte = user_level ) ) | ( Q ( pageusergroup__created_by = user ) & Q ( pagepermission__page__isnull = True ) ) ) )
similar to get_subordinate_users .