def cache_filler(): from invenio.modules.access.control import acc_get_action_id from invenio.modules.access.local_config import VIEWRESTRCOLL from invenio.modules.access.models import (AccAuthorization, AccARGUMENT) VIEWRESTRCOLL_ID = acc_get_action_id(VIEWRESTRCOLL) return [ auth[0] for auth in AccAuthorization.query.join(AccAuthorization.argument).filter( AccARGUMENT.keyword == 'collection', AccAuthorization. id_accACTION == VIEWRESTRCOLL_ID).values(AccARGUMENT.value) ]
def cache_filler(): from invenio.modules.access.control import acc_get_action_id from invenio.modules.access.local_config import VIEWRESTRCOLL from invenio.modules.access.models import ( AccAuthorization, AccARGUMENT ) VIEWRESTRCOLL_ID = acc_get_action_id(VIEWRESTRCOLL) return [auth[0] for auth in AccAuthorization.query.join( AccAuthorization.argument ).filter( AccARGUMENT.keyword == 'collection', AccAuthorization.id_accACTION == VIEWRESTRCOLL_ID ).values(AccARGUMENT.value)]
def create_infra_action_roles(): """Creates the infraaccess action in the DB""" action_id = acc_get_action_id(INFRA_ACCESS) if action_id == 0: acc_add_action(INFRA_ACCESS, "Access to the infrastructure", "no")
def index(req, c=CFG_SITE_NAME, ln=CFG_SITE_LANG, todo="", id="", doctype="", categ="", addusers="", warningText="", role=""): """Main entry point for the management of referees.""" ln = wash_language(ln) # get user ID: uid = getUid(req) (auth_code, auth_message) = acc_authorize_action(req, "cfgwebsubmit", verbose=0) if auth_code != 0: ## user is not authorised to use WebSubmit Admin: return page_not_authorized(req=req, text=auth_message) # request for deleting a user if todo == "deleteuser": acc_delete_user_role(id, name_role=role) # request for adding user(s) if todo == "adduser": role = "referee_%s_%s" % (doctype, categ[1]) roleId = acc_get_role_id(role) # if the role does not exists, we create it if roleId == 0: if acc_add_role(role, "referees for document type %s category %s" % (doctype, categ[1])) == 0: return error_page("Cannot create referee role", req, ln) else: roleId = acc_get_role_id(role) # if the action does not exist, we create it actionId = acc_get_action_id("referee") if actionId == 0: if acc_add_action("referee", "", "no", ("doctype","categ")) == 0: return error_page("Cannot create action 'referee'", req, ln) else: actionId = acc_get_action_id("referee") #create arguments arg1Id = acc_add_argument("doctype", doctype) arg2Id = acc_add_argument("categ", categ[1]) # then link the role with the action if acc_add_role_action_arguments(roleId, actionId, -1, 0, 0, [arg1Id, arg2Id]) == 0: return error_page("Cannot link role with action", req, ln) roleId = acc_get_role_id(role) # For each id in the array if isinstance(addusers, types.ListType): for adduser in addusers: # First check whether this id is not already associated with this rule myRoles = acc_get_user_roles(adduser) if not roleId in myRoles: # Actually add the role to the user acc_add_user_role(adduser, roleId) else: warningText = '<span style="color:#f00">Sorry... This user is already a referee for this category.</span>' else: # First check whether this id is not already associated with this rule myRoles = acc_get_user_roles(addusers) if not roleId in myRoles: # Actually add the role to the user acc_add_user_role(addusers, roleId) else: warningText = '<span style="color:#f00">Sorry... This user is already a referee for this category.</span>' return page(title="websubmit admin - referee selection", body=displayRefereesPage(doctype, warningText), description="", keywords="", uid=uid, language=ln, req=req)
get_self_refers_to_list from invenio.legacy.dbquery import run_sql, run_sql_with_limit, \ wash_table_column_name, get_table_update_time from invenio.legacy.webuser import getUid, collect_user_info from invenio.legacy.webpage import pageheaderonly, pagefooteronly, create_error_box, write_warning from invenio.base.i18n import gettext_set_language from invenio.utils import apache from invenio.legacy.websearch_external_collections import calculate_hosted_collections_results, do_calculate_hosted_collections_results from invenio.legacy.websearch_external_collections.config import CFG_EXTERNAL_COLLECTION_MAXRESULTS from sqlalchemy.exc import DatabaseError VIEWRESTRCOLL_ID = acc_get_action_id(VIEWRESTRCOLL) # em possible values EM_REPOSITORY={"body" : "B", "header" : "H", "footer" : "F", "search_box" : "S", "see_also_box" : "L", "basket" : "K", "alert" : "A", "search_info" : "I", "overview" : "O", "all_portalboxes" : "P", "te_portalbox" : "Pte", "tp_portalbox" : "Ptp", "np_portalbox" : "Pnp",
from invenio.utils.serializers import deserialize_via_marshal from invenio.modules.access.engine import acc_authorize_action from invenio.ext.logging import register_exception from invenio.utils.text import encode_for_xml, wash_for_utf8, strip_accents from invenio.legacy import bibrecord from invenio.legacy.dbquery import run_sql, run_sql_with_limit, \ wash_table_column_name, get_table_update_time from invenio.legacy.webuser import getUid, collect_user_info from invenio.base.i18n import gettext_set_language from invenio.utils import apache from sqlalchemy.exc import DatabaseError VIEWRESTRCOLL_ID = acc_get_action_id(VIEWRESTRCOLL) # em possible values EM_REPOSITORY = { "body": "B", "header": "H", "footer": "F", "search_box": "S", "see_also_box": "L", "basket": "K", "alert": "A", "search_info": "I", "overview": "O", "all_portalboxes": "P", "te_portalbox": "Pte", "tp_portalbox": "Ptp",
def create_infra_action_roles(): """Creates the infraaccess action in the DB""" action_id = acc_get_action_id(INFRA_ACCESS) if action_id == 0: acc_add_action(INFRA_ACCESS, "Access to the infrastructure", "no")