invenio_migrator/legacy/records.py
def _get_collection_restrictions(collection):
    """Get all restrictions for a given collection, users and fireroles."""
    try:
        from invenio.dbquery import run_sql
        from invenio.access_control_firerole import compile_role_definition
    except ImportError:
        from invenio.modules.access.firerole import compile_role_definition
        from invenio.legacy.dbquery import run_sql

    res = run_sql(
        'SELECT r.firerole_def_src, email '
        'FROM accROLE as r '
        'JOIN accROLE_accACTION_accARGUMENT ON r.id=id_accROLE '
        'JOIN accARGUMENT AS a ON a.id=id_accARGUMENT '
        'JOIN user_accROLE AS u ON r.id=u.id_accROLE '
        'JOIN user ON user.id=u.id_user '
        'WHERE a.keyword="collection" AND '
        'a.value=%s AND '
        'id_accACTION=(select id from accACTION where name="viewrestrcoll")',
        (collection, ), run_on_slave=True
    )
    fireroles = set()
    users = set()

    for f, u in res:
        fireroles.add(compile_role_definition(f))
        users.add(u)

    return {'fireroles': list(fireroles), 'users': users}
def _get_collection_restrictions(collection):
    try:
        from invenio.dbquery import run_sql
        from invenio.access_control_firerole import compile_role_definition
    except ImportError:
        from invenio.modules.access.firerole import compile_role_definition
        from invenio.legacy.dbquery import run_sql

    res = run_sql(
        'SELECT r.firerole_def_src, email '
        'FROM accROLE as r '
        'JOIN accROLE_accACTION_accARGUMENT ON r.id=id_accROLE '
        'JOIN accARGUMENT AS a ON a.id=id_accARGUMENT '
        'JOIN user_accROLE AS u ON r.id=u.id_accROLE '
        'JOIN user ON user.id=u.id_user '
        'WHERE a.keyword="collection" AND '
        'a.value=%s AND '
        'id_accACTION=(select id from accACTION where name="viewrestrcoll")',
        (collection, ), run_on_slave=True
    )
    fireroles = set()
    users = set()

    for f, u in res:
        fireroles.add(compile_role_definition(f))
        users.add(u)

    return {'fireroles': list(fireroles), 'users': users}
def _get_collection_restrictions ( collection ) : try : from invenio . dbquery import run_sql from invenio . access_control_firerole import compile_role_definition except ImportError : from invenio . modules . access . firerole import compile_role_definition from invenio . legacy . dbquery import run_sql res = run_sql ( 'SELECT r.firerole_def_src, email ' 'FROM accROLE as r ' 'JOIN accROLE_accACTION_accARGUMENT ON r.id=id_accROLE ' 'JOIN accARGUMENT AS a ON a.id=id_accARGUMENT ' 'JOIN user_accROLE AS u ON r.id=u.id_accROLE ' 'JOIN user ON user.id=u.id_user ' 'WHERE a.keyword="collection" AND ' 'a.value=%s AND ' 'id_accACTION=(select id from accACTION where name="viewrestrcoll")' , ( collection , ) , run_on_slave = True ) fireroles = set ( ) users = set ( ) for f , u in res : fireroles . add ( compile_role_definition ( f ) ) users . add ( u ) return { 'fireroles' : list ( fireroles ) , 'users' : users }
Get all restrictions for a given collection, users and fireroles.
Get all restrictions for a given collection users and fireroles .