Exemplo n.º 1
0
def get_restricted_collections_for_record(record,
                                          recreate_cache_if_needed=True):
    """Return the list of restricted collections to which record belongs."""
    if recreate_cache_if_needed:
        restricted_collection_cache.recreate_cache_if_needed()

    return set(record.get('_collections', [])) & set(
        [collection for collection in restricted_collection_cache.cache])
Exemplo n.º 2
0
def get_restricted_collections_for_record(record,
                                          recreate_cache_if_needed=True):
    """Return the list of restricted collections to which record belongs."""
    if recreate_cache_if_needed:
        restricted_collection_cache.recreate_cache_if_needed()

    return set(record.get('_collections', [])) & set([
        collection for collection in restricted_collection_cache.cache
    ])
Exemplo n.º 3
0
def get_permitted_restricted_collections(user_info,
                                         recreate_cache_if_needed=True):
    """Return a list of restricted collection with user is authorization."""
    from invenio.modules.access.engine import acc_authorize_action

    if recreate_cache_if_needed:
        restricted_collection_cache.recreate_cache_if_needed()
    ret = []

    auths = acc_authorize_action(user_info,
                                 'viewrestrcoll',
                                 batch_args=True,
                                 collection=restricted_collection_cache.cache)

    for collection, auth in zip(restricted_collection_cache.cache, auths):
        if auth[0] == 0:
            ret.append(collection)
    return ret
Exemplo n.º 4
0
def get_permitted_restricted_collections(user_info,
                                         recreate_cache_if_needed=True):
    """Return a list of restricted collection with user is authorization."""
    from invenio_access.engine import acc_authorize_action

    if recreate_cache_if_needed:
        restricted_collection_cache.recreate_cache_if_needed()
    ret = []

    auths = acc_authorize_action(
        user_info,
        'viewrestrcoll',
        batch_args=True,
        collection=restricted_collection_cache.cache
    )

    for collection, auth in zip(restricted_collection_cache.cache, auths):
        if auth[0] == 0:
            ret.append(collection)
    return ret