def get_restricted_collections_for_recid(recid, recreate_cache_if_needed=True): """Return the list of restricted collections to which recid belongs.""" if recreate_cache_if_needed: restricted_collection_cache.recreate_cache_if_needed() collection_reclist_cache.recreate_cache_if_needed() return [collection for collection in restricted_collection_cache.cache if recid in get_collection_reclist( collection, recreate_cache_if_needed=False)]
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_recid(recid, recreate_cache_if_needed=True): """Return the list of restricted collections to which recid belongs.""" if recreate_cache_if_needed: restricted_collection_cache.recreate_cache_if_needed() collection_reclist_cache.recreate_cache_if_needed() return [ collection for collection in restricted_collection_cache.cache if recid in get_collection_reclist(collection, recreate_cache_if_needed=False) ]
def get_restricted_collections_for_recid(recid, recreate_cache_if_needed=True): """Return the list of restricted collections to which recid belongs.""" from invenio_records.api import get_record if recreate_cache_if_needed: restricted_collection_cache.recreate_cache_if_needed() record = get_record(recid) 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.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