Example #1
0
def get_entries_fragment(req, year, month, day, start, limit, filter, pagerPrefix, pageNumber):
    """ Serve the request of getting only part of the result set """
    try:
        getUid(req)
    except Error:
        return "unauthorised access !"
    result = { "pagerPrefix": pagerPrefix,
               "pageNumber": pageNumber,
        }
    auth = check_user(req, 'cfgoaiharvest')
    if not auth[0]:
        return oha.perform_request_gethpdayfragment(int(year), int(month), int(day), int(limit), int(start), filter_key)
    else:
        return "unauthorised access !"
Example #2
0
def modifysynonymkb(req, idxID, ln=CFG_SITE_LANG, idxKB='', idxMATCH='', callback='yes', confirm=-1):
    navtrail_previous_links = bic.getnavtrail()
    navtrail_previous_links += """&gt; <a class="navtrail" href="%s/admin/bibindex/bibindexadmin.py/index">Manage Indexes</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 Index",
                    body=bic.perform_modifysynonymkb(idxID=idxID,
                                                     ln=ln,
                                                     idxKB=idxKB,
                                                     idxMATCH=idxMATCH,
                                                     callback=callback,
                                                     confirm=confirm),
                    uid=uid,
                    language=ln,
                    req=req,
                    navtrail = navtrail_previous_links,
                    lastupdated=__lastupdated__)
    else:
        return page_not_authorized(req=req, text=auth[1], navtrail=navtrail_previous_links)
    def getattachedfile(self, req, form):
        """
        Returns a file uploaded to the submission 'drop box' by the
        CKEditor.
        """
        argd = wash_urlargd(form, {"file": (str, None), "type": (str, None), "uid": (int, 0)})

        # Can user view this record, i.e. can user access its
        # attachments?
        uid = getUid(req)
        user_info = collect_user_info(req)

        if not argd["file"] is None:
            # Prepare path to file on disk. Normalize the path so that
            # ../ and other dangerous components are removed.
            path = os.path.abspath(
                CFG_PREFIX + "/var/tmp/attachfile/" + "/" + str(argd["uid"]) + "/" + argd["type"] + "/" + argd["file"]
            )

            # Check that we are really accessing attachements
            # directory, for the declared record.
            if path.startswith(CFG_PREFIX + "/var/tmp/attachfile/") and os.path.exists(path):
                return stream_file(req, path)

        # Send error 404 in all other cases
        return apache.HTTP_NOT_FOUND
Example #4
0
def modifyportalbox(req, colID, ln=CFG_SITE_LANG, pbxID=-1, score='', position='', sel_ln='', title='', body='', callback='yes', confirm=-1):
    navtrail_previous_links = wsc.getnavtrail() + """&gt; <a class="navtrail" href="%s/admin/websearch/websearchadmin.py/">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_modifyportalbox(colID=colID,
                                                 ln=ln,
                                                 pbxID=pbxID,
                                                 score=score,
                                                 position=position,
                                                 sel_ln=sel_ln,
                                                 title=title,
                                                 body=body,
                                                 callback=callback,
                                                 confirm=confirm),
                uid=uid,
                language=ln,
                req=req,
                navtrail = navtrail_previous_links,
                lastupdated=__lastupdated__)
    else:
        return page_not_authorized(req=req, text=auth[1], navtrail=navtrail_previous_links)
Example #5
0
def format_template_show(req, bft, code=None, ln=CFG_SITE_LANG,
                         ln_for_preview=CFG_SITE_LANG,
                         pattern_for_preview="",
                         content_type_for_preview="text/html",
                         chosen_option=""):
    """
    Main page for template edition. Check for authentication and print formats editor.

    @param req: the request object
    @param ln: language
    @param code: the code being edited
    @param bft: the name of the template to show
    @param ln_for_preview: the language for the preview (for bfo)
    @param pattern_for_preview: the search pattern to be used for the preview (for bfo)
    @param content_type_for_preview: the (MIME) content type of the preview
    @param chosen_option: returned value for dialog_box warning
    @return: a web page
    """
    ln = wash_language(ln)
    _ = gettext_set_language(ln)

    navtrail_previous_links = bibformatadminlib.getnavtrail('''
    &gt; <a class="navtrail" href="%s/admin/bibformat/bibformatadmin.py/format_templates_manage?ln=%s">%s</a>''' % (CFG_SITE_SECURE_URL, ln ,  _("Manage Format Templates")))

    try:
        uid = getUid(req)
    except MySQLdb.Error, e:
        return error_page(req)
Example #6
0
def output_format_update_attributes(req, bfo, ln=CFG_SITE_LANG,
                                    name = "", description="",
                                    code="", content_type="",
                                    names_trans=[], visibility="0"):
    """
    Update the name, description and code of given output format

    @param req: the request object
    @param ln: language
    @param description: the new description
    @param name: the new name
    @param code: the new short code (== new bfo) of the output format
    @param content_type: the new content_type of the output format
    @param bfo: the filename of the output format to update
    @param names_trans: the translations in the same order as the languages from get_languages()
    @param visibility: the visibility of the output format in the output formats list (public pages)
    @return: a web page (or redirection to a web page)
    """
    ln = wash_language(ln)
    _ = gettext_set_language(ln)

    try:
        uid = getUid(req)
    except MySQLdb.Error, e:
        return error_page(req)
Example #7
0
def format_templates_manage(req, ln=CFG_SITE_LANG, checking='0'):
    """
    Main page for formats templates management. Check for authentication and print formats list.

    @param req: the request object
    @param ln: language
    @param checking: if 0, basic checking. Else perform extensive checking (time-consuming)
    @return: a web page
    """
    ln = wash_language(ln)
    _ = gettext_set_language(ln)
    navtrail_previous_links = bibformatadminlib.getnavtrail()

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

    (auth_code, auth_msg) = check_user(req, 'cfgbibformat')
    if not auth_code:
        checking_level = wash_url_argument(checking, 'int')
        return page(title=_("Manage Format Templates"),
                body=bibformatadminlib.perform_request_format_templates_management(ln=ln, checking=checking_level),
                uid=uid,
                language=ln,
                navtrail = navtrail_previous_links,
                lastupdated=__lastupdated__,
                req=req)
    else:
        return page_not_authorized(req=req,
                                   text=auth_msg,
                                   navtrail=navtrail_previous_links)
Example #8
0
def pageheaderonly(title, navtrail="", description="", keywords="", uid=0,
                   cdspageheaderadd="", language=CFG_SITE_LANG, req=None,
                   secure_page_p=0, verbose=1, navmenuid="admin",
                   navtrail_append_title_p=1, metaheaderadd="",
                   rssurl=CFG_SITE_URL+"/rss", body_css_classes=None):
    """Return just the beginning of page(), with full headers.
       Suitable for the search results page and any long-taking scripts."""
    if req is not None:
        if uid is None:
            uid = getUid(uid)
        secure_page_p = req.is_https() and 1 or 0
    return webstyle_templates.tmpl_pageheader(req,
                      ln = language,
                      headertitle = title,
                      description = description,
                      keywords = keywords,
                      metaheaderadd = metaheaderadd,
                      userinfobox = create_userinfobox_body(req, uid, language),
                      useractivities_menu = create_useractivities_menu(req, uid, navmenuid, language),
                      adminactivities_menu = create_adminactivities_menu(req, uid, navmenuid, language),
                      navtrailbox = create_navtrailbox_body(navtrail_append_title_p \
                                                            and title or '',
                                                            navtrail,
                                                            language=language),
                      uid = uid,
                      secure_page_p = secure_page_p,
                      pageheaderadd = cdspageheaderadd,
                      navmenuid = navmenuid,
                      rssurl = rssurl,
                      body_css_classes=body_css_classes)
Example #9
0
def format_element_show_dependencies(req, bfe, ln=CFG_SITE_LANG):
    """
    Shows format element dependencies

    @param req: the request object
    @param req: the request object
    @param bfe: the name of the bfe to show
    @param ln: language
    @return: a web page
    """
    ln = wash_language(ln)
    _ = gettext_set_language(ln)
    navtrail_previous_links = bibformatadminlib.getnavtrail(''' &gt; <a class="navtrail" href="%s/admin/bibformat/bibformatadmin.py/format_elements_doc?ln=%s">%s</a>''' % (CFG_SITE_SECURE_URL, ln , _("Format Elements Documentation")))
    try:
        uid = getUid(req)
    except:
        return error_page('Error', req)

    (auth_code, auth_msg) = check_user(req, 'cfgbibformat')
    if not auth_code:
        bfe = wash_url_argument(bfe, 'str')
        return page(title=_("Format Element %s Dependencies" % bfe),
                body=bibformatadminlib.perform_request_format_element_show_dependencies(bfe=bfe, ln=ln),
                uid=uid,
                language=ln,
                navtrail = navtrail_previous_links,
                lastupdated=__lastupdated__,
                req=req)
    else:
        return page_not_authorized(req=req, text=auth_msg, navtrail=navtrail_previous_links)
Example #10
0
def output_formats_manage(req, ln=CFG_SITE_LANG, sortby="code"):
    """
    Main page for output formats management. Check for authentication and print output formats list.

    @param req: the request object
    @param ln: language
    @param sortby: the sorting crieteria (can be 'code' or 'name')
    @return: a web page
    """
    ln = wash_language(ln)
    _ = gettext_set_language(ln)
    navtrail_previous_links = bibformatadminlib.getnavtrail()

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

    (auth_code, auth_msg) = check_user(req, 'cfgbibformat')
    if not auth_code:
        sortby = wash_url_argument(sortby, 'str')
        return page(title=_("Manage Output Formats"),
                body=bibformatadminlib.perform_request_output_formats_management(ln=ln, sortby=sortby),
                uid=uid,
                language=ln,
                navtrail = navtrail_previous_links,
                lastupdated=__lastupdated__,
                req=req)
    else:
        return page_not_authorized(req=req,
                                   text=auth_msg,
                                   navtrail=navtrail_previous_links)
def format_template_show_attributes(req, bft, ln=CFG_SITE_LANG, new=0):
    """
    Page for template name and descrition attributes edition.

    This is also the first page shown when a format template
    has just been added. In that case new is different from
    False and we can offer specific option to user (for ex
    let him make a duplicate of existing template).

    @param req: the request object
    @param ln: language
    @param bft: the name of the template to show
    @param new: if "False", the template has not just been added
    @return: a web page
    """
    ln = wash_language(ln)
    _ = gettext_set_language(ln)
    navtrail_previous_links = bibformatadminlib.getnavtrail(
        """ &gt; <a class="navtrail" href="%s/admin/bibformat/bibformatadmin.py/format_templates_manage?ln=%s">%s</a>"""
        % (CFG_SITE_URL, ln, _("Manage Format Templates"))
    )

    try:
        uid = getUid(req)
    except MySQLdb.Error, e:
        return error_page(req)
def index(req, ln=CFG_SITE_LANG):
    """
    Main BibFormat administration page.

    Displays a warning if we find out that etc/biformat dir is not writable by us
    (as most opeation of BibFormat must write in this directory).

    @param req: the request object
    @param ln: language
    @return: a web page
    """
    warnings = []

    if not bibformatadminlib.can_write_etc_bibformat_dir():
        warnings.append(("WRN_BIBFORMAT_CANNOT_WRITE_IN_ETC_BIBFORMAT"))

    ln = wash_language(ln)
    _ = gettext_set_language(ln)

    # Check if user is authorized to administer
    # If not, still display page but offer to log in
    try:
        uid = getUid(req)
    except MySQLdb.Error, e:
        return error_page(req)
 def new_ticket(self, req, form):
     """handle a edit/new_ticket request"""
     argd = wash_urlargd(form, {'ln': (str, CFG_SITE_LANG), 'recid': (int, 0)})
     ln = argd['ln']
     _ = gettext_set_language(ln)
     auth_code, auth_message = acc_authorize_action(req, 'runbibedit')
     if auth_code != 0:
         return page_not_authorized(req=req, referer="/edit",
                                    text=auth_message, navtrail=navtrail)
     uid = getUid(req)
     if argd['recid']:
         (errmsg, url) = perform_request_newticket(argd['recid'], uid)
         if errmsg:
             return page(title       = _("Failed to create a ticket"),
                         body        = _("Error")+": "+errmsg,
                         errors      = [],
                         warnings    = [],
                         uid         = uid,
                         language    = ln,
                         navtrail    = navtrail,
                         lastupdated = __lastupdated__,
                         req         = req)
         else:
             #redirect..
             redirect_to_url(req, url)
    def compare_revisions(self, req, form):
        """Handle the compare revisions request"""
        argd = wash_urlargd(form, { \
                'ln': (str, CFG_SITE_LANG), \
                'rev1' : (str, ''), \
                'rev2' : (str, ''), \
                'recid': (int, 0)})

        ln = argd['ln']
        uid = getUid(req)
        _ = gettext_set_language(ln)

        # Checking if currently logged user has permission to perform this request

        auth_code, auth_message = acc_authorize_action(req, 'runbibedit')
        if auth_code != 0:
            return page_not_authorized(req=req, referer="/edit",
                                       text=auth_message, navtrail=navtrail)
        recid = argd['recid']
        rev1 = argd['rev1']
        rev2 = argd['rev2']
        ln = argd['ln']

        body, errors, warnings = perform_request_compare(ln, recid, rev1, rev2)

        return page(title = _("Comparing two record revisions"),
                    body =  body,
                    errors = errors,
                    warnings = warnings,
                    uid = uid,
                    language = ln,
                    navtrail    = navtrail,
                    lastupdated = __lastupdated__,
                    req         = req)
    def subscribe(self, req, form):
        """
        Subscribe current user to receive email notification when new
        comments are added to current discussion.
        """
        argd = wash_urlargd(form, {'referer': (str, None)})

        uid = getUid(req)

        user_info = collect_user_info(req)
        (auth_code, auth_msg) = check_user_can_view_comments(user_info, self.recid)
        if isGuestUser(uid):
            cookie = mail_cookie_create_authorize_action(VIEWRESTRCOLL, {'collection' : guess_primary_collection_of_a_record(self.recid)})
            target = '/youraccount/login' + \
                make_canonical_urlargd({'action': cookie, 'ln' : argd['ln'], 'referer' : \
                CFG_SITE_URL + user_info['uri']}, {})
            return redirect_to_url(req, target, norobot=True)
        elif auth_code:
            return page_not_authorized(req, "../", \
                text = auth_msg)

        success = subscribe_user_to_discussion(self.recid, uid)
        display_url = "%s/record/%s/comments/display?subscribed=%s&ln=%s" % \
                      (CFG_SITE_URL, self.recid, str(success), argd['ln'])
        redirect_to_url(req, display_url)
Example #16
0
def kb_add(req, ln=CFG_SITE_LANG, sortby="to", kbtype=""):
    """
    Adds a new kb
    @param req the request
    @param ln language
    @param sortby to or from
    @param kbtype type of knowledge base. one of: "", taxonomy, dynamic
    """
    ln = wash_language(ln)
    _ = gettext_set_language(ln)

    navtrail_previous_links = ''' &gt; <a class="navtrail" href="%s/kb?ln=%s">%s</a>''' % (CFG_SITE_SECURE_URL, ln, _("Manage Knowledge Bases"))

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

    (auth_code, auth_msg) = check_user(req, 'cfgbibknowledge')
    if not auth_code:
        name = "Untitled"
        if kbtype == "taxonomy":
            name = "Untitled Taxonomy"
        if kbtype == "dynamic":
            name = "Untitled dynamic"
        kb_id = bibknowledge.add_kb(kb_name=name, kb_type=kbtype)
        redirect_to_url(req, "kb?ln=%(ln)s&amp;action=attributes&amp;kb=%(kb)s" % {'ln':ln, 'kb':kb_id, 'sortby':sortby})
    else:
        navtrail_previous_links = ''' &gt; <a class="navtrail" href="%s/kb?ln=%s">%s</a>''' % (CFG_SITE_SECURE_URL, ln, _("Manage Knowledge Bases"))

        return page_not_authorized(req=req,
                                   text=auth_msg,
                                   navtrail=navtrail_previous_links)
    def sub(self, req, form):
        """DEPRECATED: /submit/sub is deprecated now, so raise email to the admin (but allow submission to continue anyway)"""
        args = wash_urlargd(form, {"password": (str, "")})
        uid = getUid(req)
        if uid == -1 or CFG_ACCESS_CONTROL_LEVEL_SITE >= 1:
            return page_not_authorized(req, "../sub/", navmenuid="submit")
        try:
            raise DeprecationWarning, 'submit/sub handler has been used. Please use submit/direct. e.g. "submit/sub?RN=123@SBIFOO" -> "submit/direct?RN=123&sub=SBIFOO"'
        except DeprecationWarning:
            register_exception(req=req, alert_admin=True)

        ln = args["ln"]
        _ = gettext_set_language(ln)
        # DEMOBOO_RN=DEMO-BOOK-2008-001&ln=en&password=1223993532.26572%40APPDEMOBOO
        params = dict(form)
        password = args["password"]
        if password:
            del params["password"]
            if "@" in password:
                params["access"], params["sub"] = password.split("@", 1)
            else:
                params["sub"] = password
        else:
            args = str(req.args).split("@")
            if len(args) > 1:
                params = {"sub": args[-1]}
                args = "@".join(args[:-1])
                params.update(cgi.parse_qs(args))
            else:
                return warningMsg(_("Sorry, invalid URL..."), req, ln=ln)
        url = "%s/submit/direct?%s" % (CFG_SITE_URL, urlencode(params, doseq=True))
        redirect_to_url(req, url)
Example #18
0
def modifyfieldvalue(req, colID, fldID, fldvID, ln=CFG_SITE_LANG, name='', value='', callback="yes", confirm=-1):
    navtrail_previous_links = wsc.getnavtrail() + """&gt; <a class="navtrail" href="%s/admin/websearch/websearchadmin.py/">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_modifyfieldvalue(colID=colID,
                                              fldID=fldID,
                                              fldvID=fldvID,
                                              ln=ln,
                                              name=name,
                                              value=value,
                                              callback=callback,
                                              confirm=confirm),
                    uid=uid,
                    language=ln,
                    navtrail = navtrail_previous_links,
                    req=req,
                    lastupdated=__lastupdated__)
    else:
        return page_not_authorized(req=req, text=auth[1], navtrail=navtrail_previous_links)
def output_format_show(
    req, bfo, ln=CFG_SITE_LANG, r_fld=[], r_val=[], r_tpl=[], default="", r_upd="", chosen_option="", **args
):
    """
    Show a single output format. Check for authentication and print output format settings.

    The page either shows the output format from file, or from user's
    POST session, as we want to let him edit the rules without
    saving. Policy is: r_fld, r_val, rules_tpl are list of attributes
    of the rules.  If they are empty, load from file. Else use
    POST. The i th value of each list is one of the attributes of rule
    i. Rule i is the i th rule in order of evaluation.  All list have
    the same number of item.

    r_upd contains an action that has to be performed on rules. It
    can composed of a number (i, the rule we want to modify) and an
    operator : "save" to save the rules, "add" or "del".
    syntax: operator [number]
    For eg: r_upd = _("Save Changes") saves all rules (no int should be specified).
    For eg: r_upd = _("Add New Rule") adds a rule (no int should be specified).
    For eg: r_upd = _("Remove Rule") + " 5"  deletes rule at position 5.
    The number is used only for operation delete.

    An action can also be in **args. We must look there for string starting
    with '(+|-) [number]' to increase (+) or decrease (-) a rule given by its
    index (number).
    For example "+ 5" increase priority of rule 5 (put it at fourth position).
    The string in **args can be followed by some garbage that looks like .x
    or .y, as this is returned as the coordinate of the click on the
    <input type="image">. We HAVE to use args and reason on its keys, because for <input> of
    type image, iexplorer does not return the value of the tag, but only the name.

    Action is executed only if we are working from user's POST session
    (means we must have loaded the output format first, which is
    totally normal and expected behaviour)


    @param req: the request object
    @param bfo: the filename of the output format to show
    @param ln: language
    @param r_fld: the list of 'field' attribute for each rule
    @param r_val: the list of 'value' attribute for each rule
    @param r_tpl: the list of 'template' attribute for each rule
    @param default: the default format template used by this output format
    @param r_upd: the rule that we want to increase/decrease in order of evaluation
    @param chosen_option: emptry string when user has not yet confirmed to go on
    @return: a web page
    """
    ln = wash_language(ln)
    _ = gettext_set_language(ln)
    navtrail_previous_links = bibformatadminlib.getnavtrail(
        """ &gt; <a class="navtrail" href="%s/admin/bibformat/bibformatadmin.py/output_formats_manage?ln=%s">%s</a>"""
        % (CFG_SITE_URL, ln, _("Manage Output Formats"))
    )
    code = wash_url_argument(bfo, "str")

    try:
        uid = getUid(req)
    except MySQLdb.Error, e:
        return error_page(req)
Example #20
0
def addcollectiontotree(req, colID, ln=CFG_SITE_LANG, add_dad='', add_son='', rtype='', mtype='', callback='yes', confirm=-1):
    navtrail_previous_links = wsc.getnavtrail() + """&gt; <a class="navtrail" href="%s/admin/websearch/websearchadmin.py/">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="WebSearch Admin",
                body=wsc.perform_addcollectiontotree(colID=colID,
                                               ln=CFG_SITE_LANG,
                                               add_dad=add_dad,
                                               add_son=add_son,
                                               rtype=rtype,
                                               callback=callback,
                                               confirm=confirm),
                uid=uid,
                language=ln,
                navtrail = navtrail_previous_links,
                req=req,
                lastupdated=__lastupdated__)
    else:
        return page_not_authorized(req=req, text=auth[1], navtrail=navtrail_previous_links)
Example #21
0
def modifycollection(req, ln=CFG_SITE_LANG, rnkID='', func='', colID='', confirm=0):
    navtrail_previous_links = brc.getnavtrail() + """&gt; <a class="navtrail" href="%s/admin/bibrank/bibrankadmin.py/">BibRank Admin Interface</a> """ % (CFG_SITE_URL)

    try:
        uid = getUid(req)
    except Error, e:
        return error_page(req)
Example #22
0
def format_elements_doc(req, ln=CFG_SITE_LANG):
    """
    Main page for format elements documentation. Check for authentication and print format elements list.

    @param req: the request object
    @param ln: language
    @return: a web page
    """
    ln = wash_language(ln)
    _ = gettext_set_language(ln)
    navtrail_previous_links = bibformatadminlib.getnavtrail()

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

    (auth_code, auth_msg) = check_user(req, 'cfgbibformat')
    if not auth_code:
        return page(title=_("Format Elements Documentation"),
                body=bibformatadminlib.perform_request_format_elements_documentation(ln=ln),
                uid=uid,
                language=ln,
                navtrail = navtrail_previous_links,
                lastupdated=__lastupdated__,
                req=req)
    else:
        return page_not_authorized(req=req,
                                   text=auth_msg,
                                   navtrail=navtrail_previous_links)
Example #23
0
def addrankarea(req, ln=CFG_SITE_LANG, rnkcode='', template='', confirm=-1):
    navtrail_previous_links = brc.getnavtrail() + """&gt; <a class="navtrail" href="%s/admin/bibrank/bibrankadmin.py/">BibRank Admin Interface</a> """ % (CFG_SITE_URL)

    try:
        uid = getUid(req)
    except Error, e:
        return error_page(req)
Example #24
0
def format_template_show_dependencies(req, bft, ln=CFG_SITE_LANG):
    """
    Show the dependencies (on elements) of the given format.

    @param req: the request object
    @param ln: language
    @param bft: the filename of the template to show
    @return: a web page
    """
    ln = wash_language(ln)
    _ = gettext_set_language(ln)
    navtrail_previous_links = bibformatadminlib.getnavtrail(''' &gt; <a class="navtrail" href="%s/admin/bibformat/bibformatadmin.py/format_templates_manage?ln=%s">%s</a>''' % (CFG_SITE_SECURE_URL, ln, _("Manage Format Templates")))

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

    (auth_code, auth_msg) = check_user(req, 'cfgbibformat')
    if not auth_code:
        format_template = wash_url_argument(bft, 'str')
        format_name = bibformat_engine.get_format_template_attrs(bft)['name']

        return page(title=_("Format Template %s Dependencies" % format_name),
                    body=bibformatadminlib.perform_request_format_template_show_dependencies(bft, ln=ln),
                    uid=uid,
                    language=ln,
                    navtrail = navtrail_previous_links,
                    lastupdated=__lastupdated__,
                    req=req)

    else:
        return page_not_authorized(req=req, text=auth_msg)
Example #25
0
def index(req, ln=CFG_SITE_LANG):
    navtrail_previous_links = brc.getnavtrail() # + """&gt; <a class="navtrail" href="%s/admin/bibrank/bibrankadmin.py">BibRank Admin Interface</a> """ % (CFG_SITE_URL)

    try:
        uid = getUid(req)
    except Error, e:
        return error_page(req)
Example #26
0
def output_format_add(req, ln=CFG_SITE_LANG):
    """
    Adds a new output format

    @param req: the request object
    @param ln: language
    @return: a web page (or redirection to a web page)
    """
    ln = wash_language(ln)
    _ = gettext_set_language(ln)

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

    (auth_code, auth_msg) = check_user(req, 'cfgbibformat')
    if not auth_code:

        bfo = bibformatadminlib.add_output_format()
        if bfo == None:
            return page(title=_("Cannot create output format"),
                        body = """BibFormat cannot add an output format.
                        Check output formats directory permissions.""",
                        language=ln,
                        lastupdated=__lastupdated__,
                        req=req)
        redirect_to_url(req, "output_format_show_attributes?ln=%(ln)s&bfo=%(bfo)s" % {'ln':ln, 'bfo':bfo})
    else:
        return page_not_authorized(req=req, text=auth_msg)
Example #27
0
def modifycollectiontree(req, colID, ln=CFG_SITE_LANG, move_up='', move_down='', move_from='', move_to='', delete='', rtype='', callback='yes', confirm=0):
    navtrail_previous_links = wsc.getnavtrail() + """&gt; <a class="navtrail" href="%s/admin/websearch/websearchadmin.py/">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="WebSearch Admin",
                body=wsc.perform_modifycollectiontree(colID=colID,
                                       ln=ln,
                                       move_up=move_up,
                                       move_down=move_down,
                                       move_from=move_from,
                                       move_to=move_to,
                                       delete=delete,
                                       rtype=rtype,
                                       callback=callback,
                                       confirm=confirm),
                uid=uid,
                language=ln,
                req=req,
                navtrail = navtrail_previous_links,
                lastupdated=__lastupdated__)
    else:
        return page_not_authorized(req=req, text=auth[1], navtrail=navtrail_previous_links)
Example #28
0
def modifyfieldtags(req, fldID, ln=CFG_SITE_LANG, callback='yes', confirm=-1):
    navtrail_previous_links = bic.getnavtrail() + """&gt; <a class="navtrail" href="%s/admin/bibindex/bibindexadmin.py/field">Manage logical fields</a> """ % (CFG_SITE_URL)

    try:
        uid = getUid(req)
    except Error, e:
        return error_page(req)
Example #29
0
def addexistingportalbox(req, colID, ln=CFG_SITE_LANG, pbxID=-1, score=0, position='', sel_ln='', callback='yes', confirm=0):
    navtrail_previous_links = wsc.getnavtrail() + """&gt; <a class="navtrail" href="%s/admin/websearch/websearchadmin.py/">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_addexistingportalbox(colID=colID,
                                                      ln=ln,
                                                      pbxID=pbxID,
                                                      score=score,
                                                      position=position,
                                                      sel_ln=sel_ln,
                                                      callback=callback,
                                                      confirm=confirm),
                uid=uid,
                language=ln,
                req=req,
                navtrail = navtrail_previous_links,
                lastupdated=__lastupdated__)
    else:
        return page(title='Authorization failure',
                uid=uid,
                body=adderrorbox('try to login first',
                                     datalist=["""You are not a user authorized to perform admin tasks, try to
                                     <a href="%s/youraccount/login?referer=%s/admin/websearch/websearchadmin.py/">login</a> with another account.""" % (CFG_SITE_SECURE_URL, CFG_SITE_URL)]),
                navtrail= navtrail_previous_links,
                lastupdated=__lastupdated__)
Example #30
0
def addtag(req, fldID, ln=CFG_SITE_LANG, name='', value='', recjson_value='', existing_tag=-1, callback='yes', confirm=-1):
    navtrail_previous_links = bic.getnavtrail() + """&gt; <a class="navtrail" href="%s/admin/bibindex/bibindexadmin.py/field">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,
                                            existing_tag=existing_tag,
                                            value=value,
                                            recjson_value=recjson_value,
                                            name=name,
                                            callback=callback,
                                            confirm=confirm),
                    uid=uid,
                    language=ln,
                    req=req,
                    navtrail = navtrail_previous_links,
                    lastupdated=__lastupdated__)
    else:
        return page_not_authorized(req=req, text=auth[1], navtrail=navtrail_previous_links)
Example #31
0
def kb_manage(req, ln=CFG_SITE_LANG, search="", descriptiontoo=""):
    """
    Main BibKnowledge administration page.

    @param ln language
    @param search search for a substring in kb names
    @param descriptiontoo .. and descriptions
    """
    ln = wash_language(ln)
    _ = gettext_set_language(ln)

    warnings = []
    # Check if user is authorized to administer
    # If not, still display page but offer to log in
    try:
        uid = getUid(req)
    except:
        return error_page('Error', req)
    (auth_code, auth_msg) = check_user(req, 'cfgbibknowledge')
    if not auth_code:
        is_admin = True
    else:
        is_admin = False

    navtrail = '''<a class="navtrail" href="%s/help/admin">%s</a>''' % \
               (CFG_SITE_SECURE_URL, _("Admin Area"))
    if is_admin:
        return page(title=_("BibKnowledge Admin"),
                    body=bibknowledgeadminlib.
                    perform_request_knowledge_bases_management(
                        ln=ln, search=search, descriptiontoo=descriptiontoo),
                    language=ln,
                    uid=uid,
                    navtrail=navtrail,
                    lastupdated=__lastupdated__,
                    req=req,
                    warnings=warnings)
    else:
        #redirect to login
        return page_not_authorized(req=req, text=auth_msg, navtrail=navtrail)
Example #32
0
def actionedit(req,
               actid,
               actname=None,
               working_dir=None,
               status_text=None,
               actcommit="",
               ln=CFG_SITE_LANG):
    """Display the details of a WebSubmit action in a Web form so that it can be viewed and/or edited.
       @param actid: The unique action identifier code.
       @param actname: name of action (if present, action will be updated, else action details will be displayed)
       @param working_dir: action working directory for websubmit
       @param status_text: status text displayed at end of websubmit action
       @param ln: language
       @return: page
    """
    ln = wash_language(ln)
    _ = gettext_set_language(ln)
    uid = getUid(req)

    (auth_code, auth_msg) = check_user(req, 'cfgwebsubmit')
    if not auth_code:
        ## user is authorised to use WebSubmit Admin:
        # Generate content
        (title, body, errors,
         warnings) = perform_request_edit_action(actid, actname, working_dir,
                                                 status_text, actcommit)
        return page(title=title,
                    body=body,
                    navtrail=get_navtrail(ln),
                    uid=uid,
                    lastupdated=__lastupdated__,
                    req=req,
                    language=ln,
                    errors=errors,
                    warnings=warnings)
    else:
        ## user is not authorised to use WebSubmit Admin:
        return page_not_authorized(req=req,
                                   text=auth_msg,
                                   navtrail=get_navtrail(ln))
Example #33
0
def kb_add(req, ln=CFG_SITE_LANG, sortby="to", kbtype=""):
    """
    Adds a new kb
    @param req the request
    @param ln language
    @param sortby to or from
    @param kbtype type of knowledge base. one of: "", taxonomy, dynamic
    """
    ln = wash_language(ln)
    _ = gettext_set_language(ln)

    navtrail_previous_links = ''' &gt; <a class="navtrail" href="%s/kb?ln=%s">%s</a>''' % (
        CFG_SITE_SECURE_URL, ln, _("Manage Knowledge Bases"))

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

    (auth_code, auth_msg) = check_user(req, 'cfgbibknowledge')
    if not auth_code:
        name = "Untitled"
        if kbtype == "taxonomy":
            name = "Untitled Taxonomy"
        if kbtype == "dynamic":
            name = "Untitled dynamic"
        kb_id = bibknowledge.add_kb(kb_name=name, kb_type=kbtype)
        redirect_to_url(
            req, "kb?ln=%(ln)s&amp;action=attributes&amp;kb=%(kb)s" % {
                'ln': ln,
                'kb': kb_id,
                'sortby': sortby
            })
    else:
        navtrail_previous_links = ''' &gt; <a class="navtrail" href="%s/kb?ln=%s">%s</a>''' % (
            CFG_SITE_SECURE_URL, ln, _("Manage Knowledge Bases"))

        return page_not_authorized(req=req,
                                   text=auth_msg,
                                   navtrail=navtrail_previous_links)
Example #34
0
def kb_dynamic_update(req, kb_id, field, expression, collection,
                      ln=CFG_SITE_LANG):
    """
    Updates the configuration of a collection based KB by checking user
    rights and calling bibknowledgeadminlib..
    @param req request
    @param kb_id knowledge base id
    @param field configured field for this dynamic kb
    @param expression search expression
    @param collection search in this collection
    @param ln language
    """
    ln = wash_language(ln)
    _ = gettext_set_language(ln)
    navtrail_previous_links = ''' &gt; <a class="navtrail" href="%s/kb?ln=%s">%s</a>''' % (CFG_SITE_URL, ln, _("Manage Knowledge Bases"))

    try:
        dummy = getUid(req)
    except MySQLdb.Error:
        return error_page(req)
    (auth_code, auth_msg) = check_user(req, 'cfgbibknowledge')
    if not auth_code:
        #actual config call
        err = bibknowledgeadminlib.perform_update_kb_config(kb_id, field,
                                                            expression,
                                                            collection)
        if err:
            return page(title=_("Error"),
                        body = err,
                        language=ln,
                        navtrail = navtrail_previous_links,
                        lastupdated=__lastupdated__,
                        req=req)

        else:
            redirect_to_url(req, "kb?ln=%(ln)s&kb=%(kb_id)s" % {'ln':ln, 'kb_id': kb_id })
    else:
        return page_not_authorized(req=req,
                                   text=auth_msg,
                                   navtrail=navtrail_previous_links)
Example #35
0
def addindex(req, ln=CFG_SITE_LANG, idxNAME='', callback="yes", confirm=-1):
    navtrail_previous_links = bic.getnavtrail() + """&gt; <a class="navtrail" href="%s/admin/bibindex/bibindexadmin.py/index">Manage Indexes</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="Manage Indexes",
                    body=bic.perform_addindex(ln=ln,
                                              idxNAME=idxNAME,
                                              callback=callback,
                                              confirm=confirm),
                    uid=uid,
                    language=ln,
                    navtrail = navtrail_previous_links,
                    req=req,
                    lastupdated=__lastupdated__)
    else:
        return page_not_authorized(req=req, text=auth[1], navtrail=navtrail_previous_links)
Example #36
0
def switchtagscore(req, fldID, id_1, id_2, ln=CFG_SITE_LANG):
    navtrail_previous_links = bic.getnavtrail() + """&gt; <a class="navtrail" href="%s/admin/bibindex/bibindexadmin.py/field">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_switchtagscore(fldID=fldID,
                                                    id_1=id_1,
                                                    id_2=id_2,
                                                    ln=ln),
                    uid=uid,
                    language=ln,
                    req=req,
                    navtrail = navtrail_previous_links,
                    lastupdated=__lastupdated__)
    else:
        return page_not_authorized(req=req, text=auth[1], navtrail=navtrail_previous_links)
Example #37
0
def field(req, ln=CFG_SITE_LANG, mtype='', content=''):
    navtrail_previous_links = bic.getnavtrail()

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

    auth = bic.check_user(req, 'cfgbibindex')
    if not auth[0]:
        return page(title="Manage logical fields",
                    body=bic.perform_field(ln=ln, mtype=mtype,
                                           content=content),
                    uid=uid,
                    language=ln,
                    req=req,
                    navtrail=navtrail_previous_links,
                    lastupdated=__lastupdated__)
    else:
        return page_not_authorized(req=req,
                                   text=auth[1],
                                   navtrail=navtrail_previous_links)
Example #38
0
def showfieldoverview(req, ln=CFG_SITE_LANG, callback='yes', confirm=-1):
    navtrail_previous_links = bic.getnavtrail() + """&gt; <a class="navtrail" href="%s/admin/bibindex/bibindexadmin.py/field">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="Manage logical fields",
                    body=bic.perform_showfieldoverview(ln=ln,
                                                 callback=callback,
                                                 confirm=confirm),
                    uid=uid,
                    language=ln,
                    req=req,
                    navtrail = navtrail_previous_links,
                    lastupdated=__lastupdated__)
    else:
        return page_not_authorized(req=req, text=auth[1], navtrail=navtrail_previous_links)
Example #39
0
def index(req, ln=CFG_SITE_LANG):
    navtrail_previous_links = brc.getnavtrail(
    )  # + """&gt; <a class="navtrail" href="%s/admin/bibrank/bibrankadmin.py">BibRank Admin Interface</a> """ % (CFG_SITE_URL)

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

    auth = brc.check_user(req, 'cfgbibrank')
    if not auth[0]:
        return page(title="BibRank Admin Interface",
                    body=brc.perform_index(ln),
                    uid=uid,
                    language=ln,
                    navtrail=navtrail_previous_links,
                    lastupdated=__lastupdated__,
                    req=req)
    else:
        return page_not_authorized(req=req,
                                   text=auth[1],
                                   navtrail=navtrail_previous_links)
    def check_authorization_moderatelinkbacks(self, req, argd):
        """
        Check if user has authorization moderate linkbacks
        @return if yes: nothing, if guest: login redirect, otherwise page_not_authorized
        """
        # Check authorization
        uid = getUid(req)
        user_info = collect_user_info(req)

        (auth_code, auth_msg) = acc_authorize_action(req, 'moderatelinkbacks', collection = guess_primary_collection_of_a_record(self.recid))
        if auth_code and user_info['email'] == 'guest':
            # Ask to login
            target = CFG_SITE_SECURE_URL + '/youraccount/login' + \
                     make_canonical_urlargd({'ln': argd['ln'],
                                             'referer': CFG_SITE_URL + user_info['uri']}, {})
            return redirect_to_url(req, target)
        elif auth_code:
            return page_not_authorized(req,
                                       referer="../",
                                       uid=uid,
                                       text=auth_msg,
                                       ln=argd['ln'])
    def toggle(self, req, form):
        """
        Store the visibility of a comment for current user
        """
        argd = wash_urlargd(form, {
            'comid': (int, -1),
            'referer': (str, None),
            'collapse': (int, 1)
        })

        uid = getUid(req)

        if isGuestUser(uid):
            # We do not store information for guests
            return ''

        toggle_comment_visibility(uid, argd['comid'], argd['collapse'],
                                  self.recid)
        if argd['referer']:
            return redirect_to_url(req, CFG_SITE_SECURE_URL + \
                                   (not argd['referer'].startswith('/') and '/' or '') + \
                                   argd['referer'] + '#' + str(argd['comid']))
Example #42
0
def format_template_delete(req, bft, ln=CFG_SITE_LANG, chosen_option=""):
    """
    Delete a format template

    @param req: the request object
    @param bft: the filename of the template to delete
    @param ln: language
    @param chosen_option: empty string when user has not yet confirm. Else "Delete" to confirm
    @return: a web page (or redirection to a web page)
    """
    ln = wash_language(ln)
    _ = gettext_set_language(ln)
    navtrail_previous_links = bibformatadminlib.getnavtrail(
        '''
    &gt; <a class="navtrail" href="%s/admin/bibformat/bibformatadmin.py/format_templates_manage?ln=%s">%s</a> &gt; %s'''
        % (CFG_SITE_SECURE_URL, ln, _("Manage Format Templates"),
           _("Delete Format Template")))

    try:
        uid = getUid(req)
    except MySQLdb.Error, e:
        return error_page(req)
    def documents(self, req, form):
        """ Display document upload form """
        argd = wash_urlargd(form, {
                                    })
        _ = gettext_set_language(argd['ln'])

        not_authorized = user_authorization(req, argd['ln'])
        if not_authorized:
            return not_authorized
        uid = getUid(req)
        body = batchuploader_templates.tmpl_display_menu(argd['ln'], ref="documents")
        body += batchuploader_templates.tmpl_display_web_docupload_form(argd['ln'])

        title = _("Document batch upload")
        return page(title = title,
                    body = body,
                    metaheaderadd = batchuploader_templates.tmpl_styles(),
                    uid = uid,
                    lastupdated = __lastupdated__,
                    req = req,
                    language = argd['ln'],
                    navmenuid = "batchuploader")
Example #44
0
def addtag(req,
           fldID,
           ln=CFG_SITE_LANG,
           name='',
           value='',
           recjson_value='',
           existing_tag=-1,
           callback='yes',
           confirm=-1):
    navtrail_previous_links = bic.getnavtrail(
    ) + """&gt; <a class="navtrail" href="%s/admin/bibindex/bibindexadmin.py/field">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,
                                            existing_tag=existing_tag,
                                            value=value,
                                            recjson_value=recjson_value,
                                            name=name,
                                            callback=callback,
                                            confirm=confirm),
                    uid=uid,
                    language=ln,
                    req=req,
                    navtrail=navtrail_previous_links,
                    lastupdated=__lastupdated__)
    else:
        return page_not_authorized(req=req,
                                   text=auth[1],
                                   navtrail=navtrail_previous_links)
def doctypeconfiguresubmissionpages(req,
                                    doctype="",
                                    action="",
                                    pagenum="",
                                    movepage="",
                                    movepagedirection="",
                                    deletepage="",
                                    deletepageconfirm="",
                                    addpage="",
                                    ln=CFG_SITE_LANG
                                   ):
    ln = wash_language(ln)
    _ = gettext_set_language(ln)
    uid = getUid(req)

    (auth_code, auth_msg) = check_user(req, 'cfgwebsubmit')
    if not auth_code:
        ## user is authorised to use WebSubmit Admin:
        (title, body, errors, warnings) = perform_request_configure_doctype_submissionpages(doctype=doctype,
                                                                                            action=action,
                                                                                            pagenum=pagenum,
                                                                                            movepage=movepage,
                                                                                            movepagedirection=movepagedirection,
                                                                                            deletepage=deletepage,
                                                                                            deletepageconfirm=deletepageconfirm,
                                                                                            addpage=addpage)
        return page(title       = title,
                    body        = body,
                    navtrail    = get_navtrail(ln),
                    uid         = uid,
                    lastupdated = __lastupdated__,
                    req         = req,
                    language    = ln,
                    errors      = errors,
                    warnings    = warnings)
    else:
        ## user is not authorised to use WebSubmit Admin:
        return page_not_authorized(req=req, text=auth_msg, navtrail=get_navtrail(ln))
def doctypelist(req, ln=CFG_SITE_LANG):
    """List all WebSubmit document types."""

    ln = wash_language(ln)
    _ = gettext_set_language(ln)
    uid = getUid(req)

    (auth_code, auth_msg) = check_user(req, 'cfgwebsubmit')
    if not auth_code:
        ## user is authorised to use WebSubmit Admin:
        (body, errors, warnings) = perform_request_list_doctypes()
        return page(title       = "Available WebSubmit Document Types",
                    body        = body,
                    navtrail    = get_navtrail(ln),
                    uid         = uid,
                    lastupdated = __lastupdated__,
                    req         = req,
                    language    = ln,
                    errors      = errors,
                    warnings    = warnings)
    else:
        ## user is not authorised to use WebSubmit Admin:
        return page_not_authorized(req=req, text=auth_msg, navtrail=get_navtrail(ln))
Example #47
0
def index(req, ln=CFG_SITE_LANG):
    """
    Menu of admin options
    @param ln: language
    """
    ln = wash_language(ln)
    _ = gettext_set_language(ln)
    navtrail_previous_links = get_navtrail()
    navtrail_previous_links +=' &gt; <a class="navtrail" href="%s/admin/weblinkback/weblinkbackadmin.py/">' % 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=_("WebLinkback Admin"),
                    body=perform_request_index(ln=ln),
                    uid=uid,
                    language=ln,
                    navtrail = navtrail_previous_links,
                    req=req)
Example #48
0
def index(req, ln=CFG_SITE_LANG, journal_name=None, action=""):
    """
    Main administration page.

    Lists the journals, and offers options to edit them, delete them
    or add new journals
    """
    navtrail_previous_links = wjn.getnavtrail()

    ln = wash_language(ln)
    _ = gettext_set_language(ln)

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

    try:
        journal_name = wash_journal_name(ln, journal_name)
        action = wash_url_argument(action, 'str')
    except InvenioWebJournalNoJournalOnServerError, e:
        # Ok, no journal. Let the admin add one...
        pass
def jschecklist(req, ln=CFG_SITE_LANG):
    """List all WebSubmit JavaScript Checks (checks can be applied to form elements in WebSubmit.)"""

    ln = wash_language(ln)
    _ = gettext_set_language(ln)
    uid = getUid(req)

    (auth_code, auth_msg) = check_user(req, 'cfgwebsubmit')
    if not auth_code:
        ## user is authorised to use WebSubmit Admin:
        (body, errors, warnings) = perform_request_list_jschecks()
        return page(title       = "Available WebSubmit Checking Functions",
                    body        = body,
                    navtrail    = get_navtrail(ln),
                    uid         = uid,
                    lastupdated = __lastupdated__,
                    req         = req,
                    language    = ln,
                    errors      = errors,
                    warnings    = warnings)
    else:
        ## user is not authorised to use WebSubmit Admin:
        return page_not_authorized(req=req, text=auth_msg, navtrail=get_navtrail(ln))
def elementlist(req, ln=CFG_SITE_LANG):
    """List all WebSubmit form ELEMENTS (elements are input fields on a WebSubmit form)"""

    ln = wash_language(ln)
    _ = gettext_set_language(ln)
    uid = getUid(req)

    (auth_code, auth_msg) = check_user(req, 'cfgwebsubmit')
    if not auth_code:
        ## user is authorised to use WebSubmit Admin:
        (body, errors, warnings) = perform_request_list_elements()
        return page(title       = "Available WebSubmit Elements",
                    body        = body,
                    navtrail    = get_navtrail(ln),
                    uid         = uid,
                    lastupdated = __lastupdated__,
                    req         = req,
                    language    = ln,
                    errors      = errors,
                    warnings    = warnings)
    else:
        ## user is not authorised to use WebSubmit Admin:
        return page_not_authorized(req=req, text=auth_msg, navtrail=get_navtrail(ln))
Example #51
0
def harvest(req, oai_src_id=None, ln=CFG_SITE_LANG, record_id=None):
    form = dict(req.form)
    content = {
        'confirm': (int, 0),
        'enable_reporting': (str, None),
        'record_id': (str, record_id),
        'oai_src_id': (str, oai_src_id),
        'ln': (str, ln),
    }
    argd = wash_urlargd(form, content)

    navtrail_previous_links = oha.getnavtrail(' &gt; <a class="navtrail" href="%s/admin/oaiharvest/oaiharvestadmin.py?ln=%s">OAI Harvest Admin Interface</a> ' \
                                              % (CFG_SITE_URL, ln), ln=ln)
    try:
        uid = getUid(req)
    except Error, e:
        return page(title="OAI Harvest Admin Interface - Error",
                    body=e,
                    uid=uid,
                    language=argd['ln'],
                    navtrail=navtrail_previous_links,
                    lastupdated=__lastupdated__,
                    req=req)
    def history(self, req, form):
        """Display upload history of the current user"""
        argd = wash_urlargd(form, {})
        _ = gettext_set_language(argd['ln'])

        not_authorized = user_authorization(req, argd['ln'])
        if not_authorized:
            return not_authorized
        uploaded_meta_files = get_user_metadata_uploads(req)
        uploaded_doc_files = get_user_document_uploads(req)

        uid = getUid(req)
        body = batchuploader_templates.tmpl_display_menu(argd['ln'], ref="history")
        body += batchuploader_templates.tmpl_upload_history(argd['ln'], uploaded_meta_files, uploaded_doc_files)
        title = _("Upload history")
        return page(title = title,
                    body = body,
                    metaheaderadd = batchuploader_templates.tmpl_styles(),
                    uid = uid,
                    lastupdated = __lastupdated__,
                    req = req,
                    language = argd['ln'],
                    navmenuid = "batchuploader")
    def daemon(self, req, form):
        """ Display content of folders where the daemon will look into """
        argd = wash_urlargd(form, {})
        _ = gettext_set_language(argd['ln'])

        not_authorized = user_authorization(req, argd['ln'])
        if not_authorized:
            return not_authorized
        docs = get_daemon_doc_files()
        metadata = get_daemon_meta_files()

        uid = getUid(req)
        body = batchuploader_templates.tmpl_display_menu(argd['ln'], ref="daemon")
        body += batchuploader_templates.tmpl_daemon_content(argd['ln'], docs, metadata)
        title = _("Batch Uploader: Daemon monitor")
        return page(title = title,
                    body = body,
                    metaheaderadd = batchuploader_templates.tmpl_styles(),
                    uid = uid,
                    lastupdated = __lastupdated__,
                    req = req,
                    language = argd['ln'],
                    navmenuid = "batchuploader")
def validate_format(req, ln=CFG_SITE_LANG, bfo=None, bft=None, bfe=None):
    """
    Returns a page showing the status of an output format or format
    template or format element. This page is called from output
    formats management page or format template management page or
    format elements documentation.

    The page only shows the status of one of the format, depending on
    the specified one. If multiple are specified, shows the first one.

    @param ln: language
    @param bfo: an output format 6 chars code
    @param bft: a format element filename
    @param bfe: a format element name
    """
    ln = wash_language(ln)
    _ = gettext_set_language(ln)


    try:
        uid = getUid(req)
    except MySQLdb.Error, e:
        return error_page(req)
Example #55
0
def modifyfieldtranslations(req, fldID, ln=CFG_SITE_LANG, sel_type='', trans = [], confirm=-1):
    navtrail_previous_links = bic.getnavtrail() + """&gt; <a class="navtrail" href="%s/admin/bibindex/bibindexadmin.py/field">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_modifyfieldtranslations(fldID=fldID,
                                                        ln=ln,
                                                        sel_type=sel_type,
                                                        trans=trans,
                                                        confirm=confirm),
                    uid=uid,
                    language=ln,
                    req=req,
                    navtrail = navtrail_previous_links,
                    lastupdated=__lastupdated__)
    else:
        return page_not_authorized(req=req, text=auth[1], navtrail=navtrail_previous_links)
def index(req, ln=CFG_SITE_LANG):
    """
    Main BibFormat administration page.

    Displays a warning if we find out that etc/biformat dir is not writable by us
    (as most opeation of BibFormat must write in this directory).

    @param ln: language
    """
    warnings = []

    if not bibformatadminlib.can_write_etc_bibformat_dir():
        warnings.append(("WRN_BIBFORMAT_CANNOT_WRITE_IN_ETC_BIBFORMAT"))

    ln = wash_language(ln)
    _ = gettext_set_language(ln)

    # Check if user is authorized to administer
    # If not, still display page but offer to log in
    try:
        uid = getUid(req)
    except MySQLdb.Error, e:
        return error_page(req)
def functionlist(req, ln=CFG_SITE_LANG):
    """List all WebSubmit FUNCTIONS (Functions do the work of processing a submission)"""

    ln = wash_language(ln)
    _ = gettext_set_language(ln)
    uid = getUid(req)

    (auth_code, auth_msg) = check_user(req, 'cfgwebsubmit')
    if not auth_code:
        ## user is authorised to use WebSubmit Admin:
        (body, errors, warnings) = perform_request_list_functions()
        return page(title       = "Available WebSubmit Functions",
                    body        = body,
                    navtrail    = get_navtrail(ln),
                    uid         = uid,
                    lastupdated = __lastupdated__,
                    req         = req,
                    language    = ln,
                    errors      = errors,
                    warnings    = warnings)
    else:
        ## user is not authorised to use WebSubmit Admin:
        return page_not_authorized(req=req, text=auth_msg, navtrail=get_navtrail(ln))
def output_format_update_attributes(req, bfo, ln=CFG_SITE_LANG,
                                    name = "", description="",
                                    code="", content_type="",
                                    names_trans=[], visibility="0"):
    """
    Update the name, description and code of given output format

    @param ln: language
    @param description: the new description
    @param name: the new name
    @param code: the new short code (== new bfo) of the output format
    @param content_type: the new content_type of the output format
    @param bfo: the filename of the output format to update
    @param names_trans: the translations in the same order as the languages from get_languages()
    @param visibility: the visibility of the output format in the output formats list (public pages)
    """
    ln = wash_language(ln)
    _ = gettext_set_language(ln)

    try:
        uid = getUid(req)
    except MySQLdb.Error, e:
        return error_page(req)
Example #59
0
def showall(req, ln=CFG_SITE_LANG):
    """Placeholder for the showall functionality"""

    ln = wash_language(ln)
    _ = gettext_set_language(ln)
    uid = getUid(req)

    (auth_code, auth_msg) = check_user(req, 'cfgwebsubmit')
    if not auth_code:
        ## user is authorised to use WebSubmit Admin:
        body = perform_request_list_doctypes()
        return page(title="Available WebSubmit Document Types",
                    body=body,
                    navtrail=get_navtrail(ln),
                    uid=uid,
                    lastupdated=__lastupdated__,
                    req=req,
                    language=ln)
    else:
        ## user is not authorised to use WebSubmit Admin:
        return page_not_authorized(req=req,
                                   text=auth_msg,
                                   navtrail=get_navtrail(ln))
Example #60
0
def modifydependentindexes(req, idxID, ln=CFG_SITE_LANG, newIDs=[], callback='yes', confirm=-1):
    navtrail_previous_links = bic.getnavtrail() + """&gt; <a class="navtrail" href="%s/admin/bibindex/bibindexadmin.py/index">Manage Indexes</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 Virtual Index",
                    body=bic.perform_modifydependentindexes(idxID=idxID,
                                                            ln=ln,
                                                            newIDs=newIDs,
                                                            callback=callback,
                                                            confirm=confirm),
                    uid=uid,
                    language=ln,
                    req=req,
                    navtrail = navtrail_previous_links,
                    lastupdated=__lastupdated__)
    else:
        return page_not_authorized(req=req, text=auth[1], navtrail=navtrail_previous_links)