How to use the invenio.webuser.getUid function in invenio

To help you get started, we’ve selected a few invenio examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github inveniosoftware / invenio / modules / bibmerge / lib / bibmerge_webinterface.py View on Github external
# Authorize access to record 1.
            auth_code, auth_message = acc_authorize_action(req, 'runbibmerge',
                collection=guess_primary_collection_of_a_record(recid1))
            if auth_code != 0:
                json_response.update({'resultCode': 1, 'resultText': 'No access to record %s' % recid1})
                return json.dumps(json_response)
        if recid2 is not None:
            # Authorize access to record 2.
            auth_code, auth_message = acc_authorize_action(req, 'runbibmerge',
                collection=guess_primary_collection_of_a_record(recid2))
            if auth_code != 0:
                json_response.update({'resultCode': 1, 'resultText': 'No access to record %s' % recid2})
                return json.dumps(json_response)

        # Handle request.
        uid = getUid(req)
        if not ajax_request:
            # Show BibEdit start page.
            body, errors, warnings = perform_request_init()
            metaheaderadd = """
  
  """ % {'site': CFG_SITE_URL}
            title = 'Record Merger'
            ln = CFG_SITE_LANG
            return page(title         = title,
                        metaheaderadd = metaheaderadd,
                        body          = body,
                        errors        = errors,
                        warnings      = warnings,
                        uid           = uid,
                        language      = ln,
                        navtrail      = navtrail,
github inveniosoftware / invenio / modules / websearch / lib / websearch_webinterface.py View on Github external
def display_collection(req, c, aas, verbose, ln, em=""):
    """Display search interface page for collection c by looking
    in the collection cache."""
    _ = gettext_set_language(ln)

    req.argd = drop_default_urlargd({'aas': aas, 'verbose': verbose, 'ln': ln, 'em' : em},
                                    search_interface_default_urlargd)

    if em != "":
        em = em.split(",")
    # get user ID:
    try:
        uid = getUid(req)
        user_preferences = {}
        if uid == -1:
            return page_not_authorized(req, "../",
                text="You are not authorized to view this collection",
                                       navmenuid='search')
        elif uid > 0:
            user_preferences = get_user_preferences(uid)
    except Error:
        register_exception(req=req, alert_admin=True)
        return page(title=_("Internal Error"),
                    body=create_error_box(req, verbose=verbose, ln=ln),
                    description="%s - Internal Error" % CFG_SITE_NAME,
                    keywords="%s, Internal Error" % CFG_SITE_NAME,
                    language=ln,
                    req=req,
                    navmenuid='search')
github inveniosoftware / invenio / modules / bibcirculation / lib / bibcirculationadminlib.py View on Github external
    @type recid:          integer.
    @param recid:         identify the record. It is also the primary key of
                          the table bibrec.

    @type borrower_id:    integer.
    @param borrower_id:   identify the borrower. It is also the primary key of
                          the table crcBORROWER.
    """

    borrower = db.get_borrower_details(borrower_id)

    navtrail_previous_links = '<a class="navtrail">Admin Area' \
                              '</a>' % (CFG_SITE_URL,)

    id_user = getUid(req)
    (auth_code, auth_message) = is_adminuser(req)
    if auth_code != 0:
        return mustloginpage(req, auth_message)

    body = bibcirculation_templates.tmpl_associate_barcode(request_id=request_id,
                                                           recid=recid,
                                                           borrower=borrower,
                                                           ln=ln)

    return page(title="Associate barcode",
                uid=id_user,
                req=req,
                body=body,
                navtrail=navtrail_previous_links,
                lastupdated=__lastupdated__)
github inveniosoftware / invenio / modules / webbasket / lib / webbasket_webinterface.py View on Github external
def write_note(self, req, form):
        """Write a comment (just interface for writing)"""

        argd = wash_urlargd(form, {'category': (str, CFG_WEBBASKET_CATEGORIES['PRIVATE']),
                                   'topic': (str, ""),
                                   'group': (int, 0),
                                   'bskid': (int, 0),
                                   'recid': (int, 0),
                                   'cmtid': (int, 0),
                                   'of'   : (str, ''),
                                   'ln': (str, CFG_SITE_LANG)})

        _ = gettext_set_language(argd['ln'])
        uid = getUid(req)
        if uid == -1 or CFG_ACCESS_CONTROL_LEVEL_SITE >= 1:
            return page_not_authorized(req, "../yourbaskets/write_note",
                                       navmenuid = 'yourbaskets')

        if isGuestUser(uid):
            if not CFG_WEBSESSION_DIFFERENTIATE_BETWEEN_GUESTS:
                return redirect_to_url(req, "%s/youraccount/login%s" % (
                    CFG_SITE_SECURE_URL,
                        make_canonical_urlargd({
                    'referer' : "%s/yourbaskets/write_note%s" % (
                        CFG_SITE_SECURE_URL,
                        make_canonical_urlargd(argd, {})),
                    "ln" : argd['ln']}, {})))

        user_info = collect_user_info(req)
        if not user_info['precached_usebaskets']:
github inveniosoftware / invenio / modules / websubmit / lib / websubmit_webinterface.py View on Github external
def _index(req, c, ln, doctype, act, startPg, access,
                   mainmenu, fromdir, nextPg, nbPg, curpage, step,
                   mode):
            auth_args = {}
            if doctype:
                auth_args['doctype'] = doctype
            if act:
                auth_args['act'] = act
            uid = getUid(req)

            if uid == -1 or CFG_ACCESS_CONTROL_LEVEL_SITE >= 1:
                return page_not_authorized(req, "direct",
                                            navmenuid='submit')

            if CFG_CERN_SITE:
                ## HACK BEGIN: this is a hack for CMS and ATLAS draft
                user_info = collect_user_info(req)
                if doctype == 'CMSPUB' and act == "" and 'cds-admin [CERN]' not in user_info['group'] and not user_info['email'].lower() == 'cds.support@cern.ch':
                    if isGuestUser(uid):
                        return redirect_to_url(req, "%s/youraccount/login%s" % (
                            CFG_SITE_SECURE_URL,
                            make_canonical_urlargd({'referer' : CFG_SITE_SECURE_URL + req.unparsed_uri, 'ln' : args['ln']}, {}))
                                               , norobot=True)
                    if 'cms-publication-committee-chair [CERN]' not in user_info['group']:
                        return page_not_authorized(req, "../submit", text="In order to access this submission interface you need to be member of the CMS Publication Committee Chair.",
github inveniosoftware / invenio / modules / weblinkback / web / admin / weblinkbackadmin.py View on Github external
def linkbacks(req, status, returncode=CFG_WEBLINKBACK_ACTION_RETURN_CODE['OK'], ln=CFG_SITE_LANG):
    """
    Display linkbacks
    @param ln: language
    @param status: of CFG_WEBLINKBACK_STATUS, currently only CFG_WEBLINKBACK_STATUS['PENDING'] is supported
    """
    return_code = int(returncode)
    ln = wash_language(ln)
    _ = gettext_set_language(ln)
    navtrail_previous_links = get_navtrail()
    navtrail_previous_links +=' &gt; <a href="%s/admin/weblinkback/weblinkbackadmin.py/" class="navtrail">' % CFG_SITE_URL
    navtrail_previous_links += _("WebLinkback Admin") + '</a>'

    uid = getUid(req)
    user_info = collect_user_info(req)
    (auth_code, auth_msg) = acc_authorize_action(user_info, 'cfgweblinkback')
    if auth_code:
        return page_not_authorized(req=req, text=auth_msg, navtrail=navtrail_previous_links)
    else:
        return page(title=_("Pending Linkbacks"),
                    body=perform_request_display_linkbacks(return_code=return_code, status=status, ln=ln),
                    uid=uid,
                    language=ln,
                    navtrail = navtrail_previous_links,
                    req=req)
github inveniosoftware / invenio / modules / bibindex / web / admin / bibindexadmin.py View on Github external
def addtag(req, fldID, ln=CFG_SITE_LANG, value=['',-1], name='', callback='yes', confirm=-1):
    navtrail_previous_links = bic.getnavtrail() + """&gt; <a href="%s/admin/bibindex/bibindexadmin.py/field" class="navtrail">Manage logical fields</a> """ % (CFG_SITE_URL)

    try:
        uid = getUid(req)
    except:
        return error_page('Error', req)

    auth = bic.check_user(req,'cfgbibindex')
    if not auth[0]:
        return page(title="Edit Logical Field",
                    body=bic.perform_addtag(fldID=fldID,
                                            ln=ln,
                                            value=value,
                                            name=name,
                                            callback=callback,
                                            confirm=confirm),
                    uid=uid,
                    language=ln,
                    req=req,
                    navtrail = navtrail_previous_links,
github inveniosoftware / invenio / modules / websearch / web / admin / websearchadmin.py View on Github external
def switchpbxscore(req, colID, id_1, id_2, sel_ln,ln=CFG_SITE_LANG):
    navtrail_previous_links = wsc.getnavtrail() + """&gt; <a href="%s/admin/websearch/websearchadmin.py/" class="navtrail">WebSearch Admin</a> """ % (CFG_SITE_URL)

    try:
        uid = getUid(req)
    except:
        return error_page('Error', req)

    auth = check_user(req,'cfgwebsearch')
    if not auth[0]:
        return page(title="Edit Collection",
                body=wsc.perform_switchpbxscore(colID=colID,
                                                ln=ln,
                                                id_1=id_1,
                                                id_2=id_2,
                                                sel_ln=sel_ln),
                uid=uid,
                language=ln,
                req=req,
                navtrail = navtrail_previous_links,
                lastupdated=__lastupdated__)
github inveniosoftware / invenio / modules / bibcirculation / lib / bibcirculationadminlib.py View on Github external
infos.append('"%s" &gt;  Unknown barcode. Please try again.' % barcode)
        body = bibcirculation_templates.tmpl_loan_return(infos=infos, ln=ln)
    else:
        borrower_id = db.get_borrower_id(barcode)
        borrower_name = db.get_borrower_name(borrower_id)
        body = bibcirculation_templates.tmpl_loan_return_confirm(borrower_name=borrower_name,
                                                                 borrower_id=borrower_id,
                                                                 recid=recid,
                                                                 barcode=barcode,
                                                                 ln=ln)

    navtrail_previous_links = '<a class="navtrail">Admin Area' \
                              '</a>' % (CFG_SITE_URL,)

    id_user = getUid(req)
    (auth_code, auth_message) = is_adminuser(req)
    if auth_code != 0:
        return mustloginpage(req, auth_message)


    return page(title="Loan return",
                uid=id_user,
                req=req,
                body=body,
                navtrail=navtrail_previous_links,
                lastupdated=__lastupdated__)
github EUDAT-B2SHARE / b2share / invenio / lib / websearch_webinterface.py View on Github external
def __call__(self, req, form):
        argd = wash_search_urlargd(form)
        argd['recid'] = self.recid
        if self.format is not None:
            argd['of'] = self.format

        req.argd = argd

        uid = getUid(req)
        user_info = collect_user_info(req)
        if uid == -1:
            return page_not_authorized(req, "../",
                text="You are not authorized to view this record.",
                                       navmenuid='search')
        elif uid > 0:
            pref = get_user_preferences(uid)
            try:
                if not form.has_key('rg'):
                    # fetch user rg preference only if not overridden via URL
                    argd['rg'] = int(pref['websearch_group_records'])
            except (KeyError, ValueError):
                pass

        if argd['rg'] > CFG_WEBSEARCH_MAX_RECORDS_IN_GROUPS and acc_authorize_action(req, 'runbibedit')[0] != 0:
            argd['rg'] = CFG_WEBSEARCH_MAX_RECORDS_IN_GROUPS