How to use the invenio.config.CFG_SITE_LANG 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 / webjournal / lib / webjournal_utils.py View on Github external
so clean the journal name. Note that language is also as returned
    from the URL, which might need to be filtered to match available
    languages (WebJournal elements can rely in bfo.lang to retrieve
    washed language)

    returns:
        args: all arguments in dict form
    """
    args = {'journal_name'  : '',
            'issue_year'    : '',
            'issue_number'  : None,
            'issue'         : None,
            'category'      : '',
            'recid'         : -1,
            'verbose'       : 0,
            'ln'            : CFG_SITE_LANG,
            'archive_year'  : None,
            'archive_search': ''}

    if not uri.startswith('/journal'):
        # Mmh, incorrect context. Still, keep language if available
        url_params = urlparse(uri)[4]
        args['ln'] = dict([part.split('=') for part in url_params.split('&') \
                           if len(part.split('=')) == 2]).get('ln', CFG_SITE_LANG)
        return args

    # Take everything after journal and before first question mark
    splitted_uri = uri.split('journal', 1)
    second_part = splitted_uri[1]
    splitted_uri = second_part.split('?')
    uri_middle_part = splitted_uri[0]
    uri_arguments = ''
github inveniosoftware / invenio / invenio / legacy / bibcheck / web / admin / bibcheckadmin.py View on Github external
def verify(req, fname, ln=CFG_SITE_LANG):
    """verify syntax by calling an external checking program"""
    ln = wash_language(ln)
    _ = gettext_set_language(ln)
    (admin_ok, uid) = is_admin(req)

    # sanity check for fname:
    fname = os.path.basename(fname)

    navtrail = """<a href="%s/help/admin" class="navtrail">%s</a>""" % \
               (CFG_SITE_SECURE_URL, _("Admin Area"))
    navtrail += """&gt; <a href="%s/admin/bibcheck/bibcheckadmin.py/" class="navtrail">BibCheck Admin</a> """ % CFG_SITE_SECURE_URL
    errors = ""
    outstr = ""
    errstr = ""
    path_to_bibcheck_cli = CFG_BINDIR + os.sep + 'bibcheck'
    if not os.path.exists(path_to_bibcheck_cli):
github inveniosoftware / invenio / modules / websearch / web / admin / websearchadmin.py View on Github external
def switchfmtscore(req, colID, type, id_1, id_2, 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_switchfmtscore(colID=colID,
                                                ln=ln,
                                                type=type,
                                                id_1=id_1,
                                                id_2=id_2),
                uid=uid,
github inveniosoftware / invenio / invenio / legacy / webjournal / utils.py View on Github external
def get_release_datetime(issue, journal_name, ln=CFG_SITE_LANG):
    """
    Gets the date at which an issue was released from the DB.
    Returns None if issue has not yet been released.

    See issue_to_datetime() to get the *theoretical* release time of an
    issue.
    """
    journal_id = get_journal_id(journal_name, ln)
    try:
        release_date = run_sql("""SELECT date_released
                                    FROM jrnISSUE
                                   WHERE issue_number=%s
                                     AND id_jrnJOURNAL=%s""",
                               (issue, journal_id))[0][0]
    except:
        return None
github inveniosoftware / invenio / modules / bibauthorid / lib / bibauthorid_webinterface.py View on Github external
def _check_user_fields(self, req, form):
        argd = wash_urlargd(
            form,
            {'ln': (str, CFG_SITE_LANG),
             'user_first_name': (str, None),
             'user_last_name': (str, None),
             'user_email': (str, None),
             'user_comments': (str, None)})
        session = get_session(req)
        pinfo = session["personinfo"]
        ulevel = pinfo["ulevel"]
        skip_checkout_faulty_fields = False

        if ulevel in ['user', 'admin']:
            skip_checkout_faulty_fields = True

        if not ("user_first_name_sys" in pinfo and pinfo["user_first_name_sys"]):
            if "user_first_name" in argd and argd['user_first_name']:
                if not argd["user_first_name"] and not skip_checkout_faulty_fields:
                    pinfo["checkout_faulty_fields"].append("user_first_name")
github inveniosoftware / invenio / modules / miscutil / lib / dateutils.py View on Github external
def create_month_selectbox(name, selected_month=0, ln=CFG_SITE_LANG):
    """
    Creates an HTML menu for month selection. Value of selected field is numeric
    @param name: name of the control (your form will be sent with name=value...)
    @param selected_month: preselect a month. use 0 for the Label 'Month'
    @param ln: language of the menu
    @return: html as string
    """
    out = "<select name="\&quot;%s\&quot;">\n"% name

    for i in range(0, 13):
        out += "</select>
github inveniosoftware / invenio / invenio / modules / comments / api.py View on Github external
def perform_request_add_comment_or_remark(recID=0,
                                          uid=-1,
                                          action='DISPLAY',
                                          ln=CFG_SITE_LANG,
                                          msg=None,
                                          score=None,
                                          note=None,
                                          priority=None,
                                          reviews=0,
                                          comID=0,
                                          client_ip_address=None,
                                          editor_type='textarea',
                                          can_attach_files=False,
                                          subscribe=False,
                                          req=None,
                                          attached_files=None,
                                          warnings=None):
    """
    Add a comment/review or remark
    @param recID: record id
github zenodo / zenodo / openaire / lib / openaire_deposit_templates.py View on Github external
def tmpl_type_options(self, text, selected_value, types, default,
                          ln=CFG_SITE_LANG, sort=True):
        items = types(ln)

        if sort:
            items.sort()

        if not selected_value:
            selected_value = default

        return self.tmpl_generic_options(
            text,
            items,
            selected_value,
            ln=CFG_SITE_LANG,
        )
github inveniosoftware / invenio / invenio / modules / search / searchext / services / MathCalculatorService.py View on Github external
    def get_description(self, ln=CFG_SITE_LANG):
        "Return service description"
        return "Return evaluated math expression"
github inveniosoftware / invenio / modules / bibrank / lib / bibrank_tag_based_indexer.py View on Github external
def getName(rank_method_code, ln=CFG_SITE_LANG, type='ln'):
    """Returns the name of the method if it exists"""

    try:
        rnkid = run_sql("SELECT id FROM rnkMETHOD where name=%s", (rank_method_code, ))
        if rnkid:
            rnkid = str(rnkid[0][0])
            res = run_sql("SELECT value FROM rnkMETHODNAME where type=%s and ln=%s and id_rnkMETHOD=%s", (type, ln, rnkid))
            if not res:
                res = run_sql("SELECT value FROM rnkMETHODNAME WHERE ln=%s and id_rnkMETHOD=%s and type=%s", (CFG_SITE_LANG, rnkid, type))
            if not res:
                return rank_method_code
            return res[0][0]
        else:
            raise Exception
    except Exception:
        write_message("Cannot run rank method, either given code for method is wrong, or it has not been added using the webinterface.")
        raise Exception