'Check if the user can indeed send a job to the given hosts
:param hosts: a list of :class:`hosts <Host>`
:type hosts: list of :class:`Host`
:param username: the name of the user that will have its privilege
checked
:type username: string or None
:raises: AclAccessViolation'

@staticmethod
def check_for_acl_violation_hosts(hosts, username=None):

    if username:
        user = User.objects.get(login=username)
    else:
        user = User.current_user()
    if user.is_superuser():
        return
    accessible_host_ids = set((host.id for host in Host.objects.filter(aclgroup__users=user)))
    unaccessible = []
    for host in hosts:
        no_access = (isinstance(host, Host) and (not host.invalid) and (int(host.id) not in accessible_host_ids))
        if no_access:
            unaccessible.append(str(host))
    if unaccessible:
        raise AclAccessViolation(('%s    does    not    have    access    to    %s' % (str(user), ','.join(unaccessible))))
