def get_user_sites_queryset(user):
 qs = Site.objects.all()
 if ((not get_cms_setting('PERMISSION')) or user.is_superuser):
  return qs
 global_ids = GlobalPagePermission.objects.with_user(user).filter((Q(can_add=True) | Q(can_change=True))).values_list('id', flat=True)
 query = Q()
 if global_ids:
  query = Q(globalpagepermission__id__in=global_ids)
  if (not qs.filter(query).exists()):
   return qs
 query |= (Q((Q(djangocms_pages__pagepermission__user=user) | Q(djangocms_pages__pagepermission__group__user=user))) & Q((Q(djangocms_pages__pagepermission__can_add=True) | Q(djangocms_pages__pagepermission__can_change=True))))
 return qs.filter(query).distinct()

def get_user_sites_queryset ( user ) : qs = Site . objects . all ( ) if ( ( not get_cms_setting ( 'PERMISSION' ) ) or user . is_superuser ) : return qs global_ids = GlobalPagePermission . objects . with_user ( user ) . filter ( ( Q ( can_add = True ) | Q ( can_change = True ) ) ) . values_list ( 'id' , flat = True ) query = Q ( ) if global_ids : query = Q ( globalpagepermission__id__in = global_ids ) if ( not qs . filter ( query ) . exists ( ) ) : return qs query |= ( Q ( ( Q ( djangocms_pages__pagepermission__user = user ) | Q ( djangocms_pages__pagepermission__group__user = user ) ) ) & Q ( ( Q ( djangocms_pages__pagepermission__can_add = True ) | Q ( djangocms_pages__pagepermission__can_change = True ) ) ) ) return qs . filter ( query ) . distinct ( )
returns queryset of all sites available for given user .