def get_user_permission_level(user, site):
 if (not user.is_authenticated()):
  raise NoPermissionsException
 if (user.is_superuser or (not get_cms_setting('PERMISSION'))):
  return ROOT_USER_LEVEL
 has_global_perms = GlobalPagePermission.objects.get_with_change_permissions(user, site.pk).exists()
 if has_global_perms:
  return ROOT_USER_LEVEL
 try:
  permission = PagePermission.objects.get_with_change_permissions(user, site).order_by('page__path')[0]
 except IndexError:
  raise NoPermissionsException
 return permission.page.depth

def get_user_permission_level ( user , site ) : if ( not user . is_authenticated ( ) ) : raise NoPermissionsException if ( user . is_superuser or ( not get_cms_setting ( 'PERMISSION' ) ) ) : return ROOT_USER_LEVEL has_global_perms = GlobalPagePermission . objects . get_with_change_permissions ( user , site . pk ) . exists ( ) if has_global_perms : return ROOT_USER_LEVEL try : permission = PagePermission . objects . get_with_change_permissions ( user , site ) . order_by ( 'page__path' ) [ 0 ] except IndexError : raise NoPermissionsException return permission . page . depth
returns highest user level from the page/permission hierarchy on which user haves can_change_permission .