code: def get_valid_users(request):
      
      Returns a list of `users` based on groups membership.
      Returns a list made of a single user when it is not member of any group.
      """
      users = [get_user(request)]
      if settings.LOCKDOWN and hasattr(request, 'user'):
          if request.user.is_authenticated:
              groups = request.user.groups.all()
              if groups:
                  users = list(User.objects.filter(groups__in=groups)
                               .values_list('username', flat=True))
          else:
              # This may happen with crafted requests
              users = []
      return users
docs: Returns a list of `users` based on groups membership.
      Returns a list made of a single user when it is not member of any group.