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])
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 ])
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
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