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)
def modifytranslations(req, rnkID='', ln=CFG_SITE_LANG, sel_type='', trans=[], confirm=0): navtrail_previous_links = brc.getnavtrail( ) + """> <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="Modify translations", body=brc.perform_modifytranslations(rnkID=rnkID, 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 addindex(req, ln=CFG_SITE_LANG, idxNAME='', callback="yes", confirm=-1): navtrail_previous_links = bic.getnavtrail( ) + """> <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)
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 addcollectiontotree(req, colID, ln=CFG_SITE_LANG, add_dad='', add_son='', rtype='', mtype='', callback='yes', confirm=-1): navtrail_previous_links = wsc.getnavtrail() + """> <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)
def modifystopwords(req, idxID, ln=CFG_SITE_LANG, idxSTOPWORDS='', callback='yes', confirm=-1): navtrail_previous_links = bic.getnavtrail() navtrail_previous_links += """> <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_modifystopwords(idxID=idxID, ln=ln, idxSTOPWORDS=idxSTOPWORDS, 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 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(''' > <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 %(x_name)s Dependencies", x_name=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)
def switchtagscore(req, fldID, id_1, id_2, ln=CFG_SITE_LANG): navtrail_previous_links = bic.getnavtrail( ) + """> <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)
def addexistingportalbox(req, colID, ln=CFG_SITE_LANG, pbxID=-1, score=0, position='', sel_ln='', callback='yes', confirm=0): navtrail_previous_links = wsc.getnavtrail() + """> <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__)
def showfieldoverview(req, ln=CFG_SITE_LANG, callback='yes', confirm=-1): navtrail_previous_links = bic.getnavtrail( ) + """> <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)
def deleteindex(req, idxID, ln=CFG_SITE_LANG, confirm=0): navtrail_previous_links = bic.getnavtrail( ) + """> <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_deleteindex(idxID=idxID, ln=ln, 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 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() + """> <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)
def modifyfieldtranslations(req, fldID, ln=CFG_SITE_LANG, sel_type='', trans=[], confirm=-1): navtrail_previous_links = bic.getnavtrail( ) + """> <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 modifyportalbox(req, colID, ln=CFG_SITE_LANG, pbxID=-1, score='', position='', sel_ln='', title='', body='', callback='yes', confirm=-1): navtrail_previous_links = wsc.getnavtrail() + """> <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)
def modifyfieldvalue(req, colID, fldID, fldvID, ln=CFG_SITE_LANG, name='', value='', callback="yes", confirm=-1): navtrail_previous_links = wsc.getnavtrail() + """> <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 modifysynonymkb(req, idxID, ln=CFG_SITE_LANG, idxKB='', idxMATCH='', callback='yes', confirm=-1): navtrail_previous_links = bic.getnavtrail() navtrail_previous_links += """> <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 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)
def issue_control(req, journal_name="", issue=[], ln=CFG_SITE_LANG, action="cfg"): """ Page that allows full control over creating, backtracing, adding to, removing from issues. """ navtrail_previous_links = wjn.getnavtrail( ' > <a class="navtrail" href="%s/admin/webjournal/webjournaladmin.py">WebJournal Admin</a> > <a class="navtrail" href="%s/admin/webjournal/webjournaladmin.py/administrate?journal_name=%s">%s</a>' % (CFG_SITE_URL, CFG_SITE_URL, journal_name, journal_name)) 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') issue = wash_url_argument(issue, 'list') issues = [wash_issue_number(ln,journal_name, _issue) \ for _issue in issue \ if _issue != "ww/YYYY"] except InvenioWebJournalNoJournalOnServerError as e: register_exception(req=req) return e.user_box() except InvenioWebJournalNoNameError as e: register_exception(req=req) return e.user_box() except InvenioWebJournalNoCurrentIssueError as e: register_exception(req=req) return e.user_box() except InvenioWebJournalIssueNumberBadlyFormedError as e: register_exception(req=req) return e.user_box() auth = acc_authorize_action(getUid(req), 'cfgwebjournal', name="%s" % journal_name, with_editor_rights='yes') if auth[0] == 0: return page(title=_("Publishing Interface"), body=wjn.perform_request_issue_control( journal_name=journal_name, issues=issues, ln=ln, action=action), 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 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)
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(''' > <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 %(x_name)s Dependencies", x_name=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)
def addrankarea(req, ln=CFG_SITE_LANG, rnkcode='', template='', confirm=-1): navtrail_previous_links = brc.getnavtrail( ) + """> <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="Add new rank method", body=brc.perform_addrankarea(rnkcode=rnkcode, ln=ln, template=template, 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 modifytag(req, fldID, tagID, ln=CFG_SITE_LANG, name='', value='', callback='yes', confirm=-1): navtrail_previous_links = bic.getnavtrail() + """> <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_modifytag(fldID=fldID, tagID=tagID, ln=ln, name=name, value=value, 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 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 = ''' > <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&action=attributes&kb=%(kb)s" % {'ln':ln, 'kb':kb_id, 'sortby':sortby}) else: navtrail_previous_links = ''' > <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 index(req, ln=CFG_SITE_LANG, action='', bsrID='', sm_name='', sm_def_type='', sm_def_value='', sm_washer='', sm_locale=''): """ Display the initial(main) page """ navtrail_previous_links = bsc.getnavtrail() try: uid = getUid(req) except: return error_page('Error', req) auth = bsc.check_user(req,'cfgbibsort') if not auth[0]: action = wash_url_argument(action, 'str') bsrID = wash_url_argument(bsrID, 'int') sm_name = wash_url_argument(sm_name, 'str') sm_def_type = wash_url_argument(sm_def_type, 'str') sm_def_value = wash_url_argument(sm_def_value, 'str') sm_washer = wash_url_argument(sm_washer, 'str') sm_locale = wash_url_argument(sm_locale, 'str') return page(title="BibSort Admin Interface", body=bsc.perform_index(ln, action, bsrID, sm_name, sm_def_type, sm_def_value, sm_washer, sm_locale), 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 kb_delete(req, kb, ln=CFG_SITE_LANG, chosen_option=""): """ Deletes an existing kb @param kb the kb id to delete """ ln = wash_language(ln) _ = gettext_set_language(ln) navtrail_previous_links = """ > <a class="navtrail" href="%s/kb?ln=%s">%s</a> > %s""" % ( CFG_SITE_SECURE_URL, ln, _("Manage Knowledge Bases"), _("Delete Knowledge Base"), ) try: dummy = getUid(req) except: return error_page("Error", req) (auth_code, auth_msg) = check_user(req, "cfgbibknowledge") if not auth_code: kb_id = wash_url_argument(kb, "int") kb_name = bibknowledge.get_kb_name(kb_id) if kb_name is None: return page( title=_("Unknown Knowledge Base"), body="", language=ln, navtrail=navtrail_previous_links, errors=[("ERR_KB_ID_UNKNOWN", kb)], lastupdated=__lastupdated__, req=req, ) # Ask confirmation to user if not already done chosen_option = wash_url_argument(chosen_option, "str") if chosen_option == "": return dialog_box( req=req, ln=ln, title="Delete %s" % kb_name, message="""Are you sure you want to delete knowledge base <i>%s</i>?""" % kb_name, navtrail=navtrail_previous_links, options=[_("Cancel"), _("Delete")], ) elif chosen_option == _("Delete"): bibknowledge.delete_kb(kb_name) redirect_to_url(req, "kb?ln=%(ln)s" % {"ln": ln}) else: navtrail_previous_links = """ > <a class="navtrail" href="%s/kb">%s</a>""" % ( CFG_SITE_SECURE_URL, _("Manage Knowledge Bases"), ) return page_not_authorized(req=req, text=auth_msg, navtrail=navtrail_previous_links)
def kb_show(req, kb, sortby="to", ln=CFG_SITE_LANG, startat=0, search=""): """ Shows the content of the given knowledge base id. Check for authentication and kb existence. Before displaying the content of the knowledge base, check if a form was submitted asking for adding, editing or removing a value. @param ln language @param kb the kb id to show @param sortby the sorting criteria ('from' or 'to') @param startat the number from which start showing mapping rules in kb @param search search for this string in the kb """ ln = wash_language(ln) _ = gettext_set_language(ln) navtrail_previous_links = """ > <a class="navtrail" href="%s/kb?ln=%s">%s</a>""" % ( CFG_SITE_SECURE_URL, ln, _("Manage Knowledge Bases"), ) try: uid = getUid(req) except: return error_page("Error", req) (auth_code, auth_msg) = check_user(req, "cfgbibknowledge") if not auth_code: kb_id = wash_url_argument(kb, "int") kb_name = bibknowledge.get_kb_name(kb_id) if kb_name is None: return page( title=_("Unknown Knowledge Base"), body="", language=ln, navtrail=navtrail_previous_links, errors=[("ERR_KB_ID_UNKNOWN", kb)], lastupdated=__lastupdated__, req=req, ) return page( title=_("Knowledge Base %(x_name)s", x_name=kb_name), body=bibknowledgeadminlib.perform_request_knowledge_base_show( ln=ln, kb_id=kb_id, sortby=sortby, startat=startat, search_term=search ), 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 kb_show(req, kb, sortby="to", ln=CFG_SITE_LANG, startat=0, search=""): """ Shows the content of the given knowledge base id. Check for authentication and kb existence. Before displaying the content of the knowledge base, check if a form was submitted asking for adding, editing or removing a value. @param ln language @param kb the kb id to show @param sortby the sorting criteria ('from' or 'to') @param startat the number from which start showing mapping rules in kb @param search search for this string in the kb """ ln = wash_language(ln) _ = gettext_set_language(ln) navtrail_previous_links = ''' > <a class="navtrail" href="%s/kb?ln=%s">%s</a>''' % (CFG_SITE_SECURE_URL, ln, _("Manage Knowledge Bases")) try: uid = getUid(req) except: return error_page('Error', req) (auth_code, auth_msg) = check_user(req, 'cfgbibknowledge') if not auth_code: kb_id = wash_url_argument(kb, 'int') kb_name = bibknowledge.get_kb_name(kb_id) if kb_name is None: return page(title=_("Unknown Knowledge Base"), body="", language=ln, navtrail=navtrail_previous_links, errors=[("ERR_KB_ID_UNKNOWN", kb)], lastupdated=__lastupdated__, req=req) return page( title=_("Knowledge Base %(x_name)s", x_name=kb_name), body=bibknowledgeadminlib.perform_request_knowledge_base_show( ln=ln, kb_id=kb_id, sortby=sortby, startat=startat, search_term=search), 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 kb_edit_mapping(req, kb, key, mapFrom, mapTo, update="", delete="", sortby="to", ln=CFG_SITE_LANG): """ Edit a mapping to in kb. Edit can be "update old value" or "delete existing value" @param kb the knowledge base id to edit @param key the key of the mapping that will be modified @param mapFrom the new key of the mapping @param mapTo the new value of the mapping @param update contains a value if the mapping is to be updated @param delete contains a value if the mapping is to be deleted @param sortby the sorting criteria ('from' or 'to') """ ln = wash_language(ln) _ = gettext_set_language(ln) navtrail_previous_links = """ > <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: kb_id = wash_url_argument(kb, "int") kb_name = bibknowledge.get_kb_name(kb_id) if kb_name is None: return page( title=_("Unknown Knowledge Base"), body="", language=ln, navtrail=navtrail_previous_links, errors=[("ERR_KB_ID_UNKNOWN", kb)], lastupdated=__lastupdated__, req=req, ) key = wash_url_argument(key, "str") if delete != "": # Delete bibknowledge.remove_kb_mapping(kb_name, key) if update != "": # Update new_key = wash_url_argument(mapFrom, "str") new_value = wash_url_argument(mapTo, "str") bibknowledge.update_kb_mapping(kb_name, key, new_key, new_value) redirect_to_url(req, "kb?ln=%(ln)s&kb=%(kb)s&sortby=%(sortby)s" % {"ln": ln, "kb": kb_id, "sortby": sortby}) 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(''' > <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'] is_new = wash_url_argument(new, 'int') if not bibformatadminlib.can_read_format_template(bft): #No read permission try: raise InvenioBibFormatError(_('Format template %(x_name)s cannot not be read. %(x_text)s', x_name=format_template, x_text="")) except InvenioBibFormatError as exc: register_exception(req=req) return page(title=_("Restricted Format Template"), body = """You don't have permission to view this format template.""", language=ln, navtrail = navtrail_previous_links, lastupdated=__lastupdated__, req=req) return page(title=_("Format Template %(x_name)s Attributes", x_name=format_name), body=bibformatadminlib.perform_request_format_template_show_attributes(bft, ln=ln, new=is_new), uid=uid, language=ln, navtrail = navtrail_previous_links , lastupdated=__lastupdated__, req=req) else: return page_not_authorized(req=req, text=auth_msg)
def kb_delete(req, kb, ln=CFG_SITE_LANG, chosen_option=""): """ Deletes an existing kb @param kb the kb id to delete """ ln = wash_language(ln) _ = gettext_set_language(ln) navtrail_previous_links = ''' > <a class="navtrail" href="%s/kb?ln=%s">%s</a> > %s''' % ( CFG_SITE_SECURE_URL, ln, _("Manage Knowledge Bases"), _("Delete Knowledge Base")) try: dummy = getUid(req) except: return error_page('Error', req) (auth_code, auth_msg) = check_user(req, 'cfgbibknowledge') if not auth_code: kb_id = wash_url_argument(kb, 'int') kb_name = bibknowledge.get_kb_name(kb_id) if kb_name is None: return page(title=_("Unknown Knowledge Base"), body="", language=ln, navtrail=navtrail_previous_links, errors=[("ERR_KB_ID_UNKNOWN", kb)], lastupdated=__lastupdated__, req=req) #Ask confirmation to user if not already done chosen_option = wash_url_argument(chosen_option, 'str') if chosen_option == "": return dialog_box(req=req, ln=ln, title="Delete %s" % kb_name, message="""Are you sure you want to delete knowledge base <i>%s</i>?""" % kb_name, navtrail=navtrail_previous_links, options=[_("Cancel"), _("Delete")]) elif chosen_option == _("Delete"): bibknowledge.delete_kb(kb_name) redirect_to_url(req, "kb?ln=%(ln)s" % {'ln': ln}) else: navtrail_previous_links = ''' > <a class="navtrail" href="%s/kb">%s</a>''' % ( CFG_SITE_SECURE_URL, _("Manage Knowledge Bases")) return page_not_authorized(req=req, text=auth_msg, navtrail=navtrail_previous_links)
def is_admin(req): """checks if the user has the rights (etc)""" # Check if user is authorized to administer uid = 0 try: uid = getUid(req) except: return error_page('Error', req) (auth_code, auth_msg) = check_user(req, 'cfgbibformat') if not auth_code: return (True, uid) else: return (False, uid)
def issue_control(req, journal_name="", issue=[], ln=CFG_SITE_LANG, action="cfg"): """ Page that allows full control over creating, backtracing, adding to, removing from issues. """ navtrail_previous_links = wjn.getnavtrail(' > <a class="navtrail" href="%s/admin/webjournal/webjournaladmin.py">WebJournal Admin</a> > <a class="navtrail" href="%s/admin/webjournal/webjournaladmin.py/administrate?journal_name=%s">%s</a>' % (CFG_SITE_URL, CFG_SITE_URL, journal_name, journal_name)) 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') issue = wash_url_argument(issue, 'list') issues = [wash_issue_number(ln,journal_name, _issue) \ for _issue in issue \ if _issue != "ww/YYYY"] except InvenioWebJournalNoJournalOnServerError as e: register_exception(req=req) return e.user_box() except InvenioWebJournalNoNameError as e: register_exception(req=req) return e.user_box() except InvenioWebJournalNoCurrentIssueError as e: register_exception(req=req) return e.user_box() except InvenioWebJournalIssueNumberBadlyFormedError as e: register_exception(req=req) return e.user_box() auth = acc_authorize_action(getUid(req), 'cfgwebjournal', name="%s" % journal_name, with_editor_rights='yes') if auth[0] == 0: return page(title=_("Publishing Interface"), body=wjn.perform_request_issue_control(journal_name=journal_name, issues=issues, ln=ln, action=action), 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 feature_record(req, journal_name="", recid="", img_url="", ln=CFG_SITE_LANG, action=""): """ Interface to feature a record. Will be saved in a flat file. """ navtrail_previous_links = wjn.getnavtrail( ' > <a class="navtrail" href="%s/admin/webjournal/webjournaladmin.py">WebJournal Admin</a> > <a class="navtrail" href="%s/admin/webjournal/webjournaladmin.py/administrate?journal_name=%s">%s</a>' % (CFG_SITE_URL, CFG_SITE_URL, journal_name, journal_name)) 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) except InvenioWebJournalNoJournalOnServerError as e: register_exception(req=req) return e.user_box() except InvenioWebJournalNoNameError as e: register_exception(req=req) return e.user_box() auth = acc_authorize_action(getUid(req), 'cfgwebjournal', name="%s" % journal_name, with_editor_rights='yes') if auth[0] == 0: return page(title=_("Feature a record"), body=wjn.perform_feature_record(ln=ln, journal_name=journal_name, recid=recid, img_url=img_url, action=action), 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 regenerate(req, journal_name="", issue="", ln=CFG_SITE_LANG, confirmed_p="", publish_draft_articles_p=""): """ Clears the cache for the given issue. """ navtrail_previous_links = wjn.getnavtrail(' > <a class="navtrail" href="%s/admin/webjournal/webjournaladmin.py">WebJournal Admin</a> > <a class="navtrail" href="%s/admin/webjournal/webjournaladmin.py/administrate?journal_name=%s">%s</a>' % (CFG_SITE_URL, CFG_SITE_URL, journal_name, journal_name)) 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) issue_number = wash_issue_number(ln, journal_name, issue) confirmed_p = wash_url_argument(confirmed_p, 'str') == "confirmed" publish_draft_articles_p = wash_url_argument(publish_draft_articles_p, 'str') == "move" except InvenioWebJournalNoJournalOnServerError as e: register_exception(req=req) return e.user_box() except InvenioWebJournalNoNameError as e: register_exception(req=req) return e.user_box() except InvenioWebJournalNoCurrentIssueError as e: register_exception(req=req) return e.user_box() except InvenioWebJournalIssueNumberBadlyFormedError as e: register_exception(req=req) return e.user_box() auth = acc_authorize_action(getUid(req), 'cfgwebjournal', name="%s" % journal_name) if auth[0] == 0: return page(title=confirmed_p and _("Issue regenerated") or _("Regenerate Issue"), body=wjn.perform_regenerate_issue(ln=ln, journal_name=journal_name, issue=issue, confirmed_p=confirmed_p, publish_draft_articles_p=publish_draft_articles_p), 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 kb_show_dependencies(req, kb, ln=CFG_SITE_LANG, sortby="to"): """ Shows the dependencies of a given kb @param kb the kb id to show @param ln language @param sortby the sorting criteria ('from' or 'to') """ ln = wash_language(ln) _ = gettext_set_language(ln) navtrail_previous_links = """ > <a class="navtrail" href="%s/kb?ln=%s">%s</a>""" % ( CFG_SITE_SECURE_URL, ln, _("Manage Knowledge Bases"), ) try: uid = getUid(req) except: return error_page("Error", req) (auth_code, auth_msg) = check_user(req, "cfgbibknowledge") if not auth_code: kb_id = wash_url_argument(kb, "int") kb_name = bibknowledge.get_kb_name(kb_id) if kb_name is None: return page( title=_("Unknown Knowledge Base"), body="", language=ln, navtrail=navtrail_previous_links, errors=[("ERR_KB_ID_UNKNOWN", kb)], lastupdated=__lastupdated__, req=req, ) return page( title=_("Knowledge Base %(x_name)s Dependencies", x_name=kb_name), body=bibknowledgeadminlib.perform_request_knowledge_base_show_dependencies( ln=ln, kb_id=kb_id, 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 configure(req, journal_name=None, ln=CFG_SITE_LANG, xml_config=u'', action='edit'): """ Let admins configure the journal settings """ ln = wash_language(ln) _ = gettext_set_language(ln) if journal_name is None: navtrail_previous_links = wjn.getnavtrail(' > <a class="navtrail" href="%s/admin/webjournal/webjournaladmin.py">WebJournal Admin</a>' % CFG_SITE_URL) else: navtrail_previous_links = wjn.getnavtrail(' > <a class="navtrail" href="%s/admin/webjournal/webjournaladmin.py">WebJournal Admin</a> > <a class="navtrail" href="%s/admin/webjournal/webjournaladmin.py/administrate?journal_name=%s">%s</a>' % (CFG_SITE_URL, CFG_SITE_URL, journal_name, journal_name)) if action in ['add', 'addDone']: page_title = _('Add Journal') else: page_title = _("Edit Settings") try: uid = getUid(req) except: return error_page('Error', req) try: journal_name = wash_journal_name(ln, journal_name, guess=False) xml_config = wash_url_argument(xml_config, 'str') action = wash_url_argument(action, 'str') except InvenioWebJournalNoJournalOnServerError as e: # Ok, no journal. Let the admin add one... pass except InvenioWebJournalNoNameError as e: register_exception(req=req) return e.user_box() auth = acc_authorize_action(getUid(req), 'cfgwebjournal', name="%s" % journal_name, with_editor_rights='yes') if auth[0] == 0: return page(title=page_title, body=wjn.perform_request_configure(journal_name=journal_name, ln=ln, xml_config=xml_config, action=action), 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 output_format_show_attributes(req, bfo, ln=CFG_SITE_LANG): """ Page for output format names and descrition attributes edition. @param req: the request object @param ln: language @param bfo: the filename of the template to show @return: a web page """ ln = wash_language(ln) _ = gettext_set_language(ln) navtrail_previous_links = bibformatadminlib.getnavtrail(''' > <a class="navtrail" href="%s/admin/bibformat/bibformatadmin.py/output_formats_manage?ln=%s">%s</a>''' % (CFG_SITE_SECURE_URL, ln , _("Manage Output Formats"))) try: uid = getUid(req) except: return error_page('Error', req) (auth_code, auth_msg) = check_user(req, 'cfgbibformat') if not auth_code: bfo = wash_url_argument(bfo, 'str') if not bibformatadminlib.can_read_output_format(bfo): #No read permission try: raise InvenioBibFormatError(_('Output format %(x_name)s cannot not be read. %(x_text)s', x_name=bfo, x_text="")) except InvenioBibFormatError as exc: register_exception(req=req) return page(title=_("Restricted Output Format"), body = """You don't have permission to view this output format.""", language=ln, navtrail = navtrail_previous_links, lastupdated=__lastupdated__, req=req) output_format = bibformat_engine.get_output_format(code=bfo, with_attributes=True) name = output_format['attrs']['names']['generic'] return page(title=_("Output Format %(x_name)s Attributes", x_name=name), body=bibformatadminlib.perform_request_output_format_show_attributes(bfo, ln=ln), uid=uid, language=ln, navtrail = navtrail_previous_links , lastupdated=__lastupdated__, req=req) else: return page_not_authorized(req=req, text=auth_msg)
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 as e: # Ok, no journal. Let the admin add one... pass except InvenioWebJournalNoNameError as e: register_exception(req=req) return e.user_box() if action in ['delete', 'askDelete']: # To perform these, one must be authorized auth = acc_authorize_action(getUid(req), 'cfgwebjournal', name=journal_name, with_editor_rights='yes') else: auth = acc_authorize_action(getUid(req), 'cfgwebjournal') if auth[0] == 0: return page(title=_('WebJournal Admin'), body=wjn.perform_index(ln=ln, journal_name=journal_name, action=action, uid=getUid(req)), 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 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: return error_page('Error', req) (auth_code, auth_msg) = check_user(req, 'cfgbibformat') if not auth_code: name = wash_url_argument(name, 'str') description = wash_url_argument(description, 'str') bfo = wash_url_argument(bfo, 'str') code = wash_url_argument(code, 'str') visibility = wash_url_argument(visibility, 'int') bfo = bibformatadminlib.update_output_format_attributes(bfo, name, description, code, content_type, names_trans, visibility) redirect_to_url(req, "output_format_show?ln=%(ln)s&bfo=%(bfo)s" % {'ln':ln, 'bfo':bfo, 'names_trans':names_trans}) else: return page_not_authorized(req=req, text=auth_msg)
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 = ''' > <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: #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)
def kb_show_attributes(req, kb, ln=CFG_SITE_LANG, sortby="to"): """ Shows the attributes (name, description) of a given kb @param ln language @param kb the kb id to show @param sortby the sorting criteria ('from' or 'to') """ ln = wash_language(ln) _ = gettext_set_language(ln) navtrail_previous_links = ''' > <a class="navtrail" href="%s/kb?ln=%s">%s</a>''' % ( CFG_SITE_SECURE_URL, ln, _("Manage Knowledge Bases")) try: uid = getUid(req) except: return error_page('Error', req) (auth_code, auth_msg) = check_user(req, 'cfgbibknowledge') if not auth_code: kb_id = wash_url_argument(kb, 'int') kb_name = bibknowledge.get_kb_name(kb_id) if kb_name is None: return page(title=_("Unknown Knowledge Base"), body="", language=ln, navtrail=navtrail_previous_links, errors=[("ERR_KB_ID_UNKNOWN", kb)], lastupdated=__lastupdated__, req=req) return page(title=_("Knowledge Base %(x_name)s Attributes", x_name=kb_name), body=bibknowledgeadminlib. perform_request_knowledge_base_show_attributes( ln=ln, kb_id=kb_id, 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 administrate(req, journal_name, ln=CFG_SITE_LANG): """ Shows the settings of a journal """ navtrail_previous_links = wjn.getnavtrail( ' > <a class="navtrail" href="%s/admin/webjournal/webjournaladmin.py">WebJournal Admin</a>' % CFG_SITE_URL) 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) except InvenioWebJournalNoJournalOnServerError as e: register_exception(req=req) return e.user_box() except InvenioWebJournalNoNameError as e: register_exception(req=req) return e.user_box() auth = acc_authorize_action(getUid(req), 'cfgwebjournal', name="%s" % journal_name) if auth[0] == 0: as_editor = acc_authorize_action(getUid(req), 'cfgwebjournal', name="%s" % journal_name, with_editor_rights='yes')[0] == 0 return page(title=_('Administrate %(journal_name)s' % {'journal_name': journal_name}), body=wjn.perform_administrate(ln=ln, journal_name=journal_name, as_editor=as_editor), 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 req: the request object @param ln: language @return: a web page """ warnings = [] ln = wash_language(ln) _ = gettext_set_language(ln) if not bibformatadminlib.can_write_etc_bibformat_dir(): try: raise InvenioBibFormatWarning(_('Cannot write in etc/bibformat dir of your Invenio installation. Check directory permission.')) except InvenioBibFormatWarning as exc: register_exception(stream='warning', req=req) warnings.append(exc.message) # 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, 'cfgbibformat') 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")) return page(title=_("BibFormat Admin"), body=bibformatadminlib.perform_request_index(ln=ln, warnings=warnings, is_admin=is_admin), language=ln, uid=uid, navtrail = navtrail, lastupdated=__lastupdated__, req=req)
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 as e: # Ok, no journal. Let the admin add one... pass except InvenioWebJournalNoNameError as e: register_exception(req=req) return e.user_box() if action in ['delete', 'askDelete']: # To perform these, one must be authorized auth = acc_authorize_action(getUid(req), 'cfgwebjournal', name=journal_name, with_editor_rights='yes') else: auth = acc_authorize_action(getUid(req), 'cfgwebjournal') if auth[0] == 0: return page(title=_('WebJournal Admin'), body=wjn.perform_index(ln=ln, journal_name=journal_name, action=action, uid=getUid(req)), 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 update_external_collections(req, colID, ln=CFG_SITE_LANG, state=None, recurse=None): navtrail_previous_links = wsc.getnavtrail() + """> <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_update_external_collections(colID, ln, state, recurse), 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): navtrail_previous_links = brc.getnavtrail() # + """> <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 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 = ''' > <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.decode('utf-8'), kb_type=kbtype) redirect_to_url( req, "kb?ln=%(ln)s&action=attributes&kb=%(kb)s" % { 'ln': ln, 'kb': kb_id, 'sortby': sortby }) else: navtrail_previous_links = ''' > <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 runwebcoll(req, colID, ln=CFG_SITE_LANG, confirm=0): navtrail_previous_links = wsc.getnavtrail() + """> <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_checkwebcollstatus(colID=colID, ln=ln, 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 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)
def update_detailed_record_options(req, colID, ln=CFG_SITE_LANG, tabs=[], recurse=0): """Update the preferences for the tab to show/hide in the detailed record page. """ _tabs = wash_url_argument(tabs, 'list') navtrail_previous_links = wsc.getnavtrail() + """> <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_update_detailed_record_options(colID, ln, _tabs, recurse), 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): navtrail_previous_links = brc.getnavtrail( ) # + """> <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 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)
def addtag(req, fldID, ln=CFG_SITE_LANG, name='', value='', recjson_value='', existing_tag=-1, callback='yes', confirm=-1): navtrail_previous_links = bic.getnavtrail( ) + """> <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)