'Returns Objects the given user is allowed to access, depending on mode - read(r), write(w) or execute(x)'

def filter_permitted(user, manager, mode='r', filter_trash=True):

    if (not user):
        return []
    query = models.Q()
    for imode in mode:
        query = (query & Object._get_query_filter_permitted(user, imode, filter_trash))
    objects = manager.filter(query).distinct()
    return objects
