コード例 #1
0
ファイル: websearchadmin.py プロジェクト: chokribr/invenio-1
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__)
コード例 #2
0
ファイル: websearchadmin.py プロジェクト: chokribr/invenio-1
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)
コード例 #3
0
ファイル: websearchadmin.py プロジェクト: chokribr/invenio-1
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)
コード例 #4
0
def viewhistoryday(req, oai_src_id=0, ln=CFG_SITE_LANG, year=None, month=None, day=None, start=0):
    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)
    d_date = datetime.datetime.now()
    if year == None:
        year = d_date.year
    if month == None:
        month = d_date.month
    if day == None:
        day = d_date.day
    try:
        uid = getUid(req)
    except Error as e:
        return page(title="OAI Harvest Admin Interface - Error",
                    body=e,
                    uid=uid,
                    language=ln,
                    navtrail = navtrail_previous_links,
                    lastupdated=__lastupdated__,
                    req=req)
    auth = check_user(req,'cfgoaiharvest')
    if not auth[0]:
        return page(title="View OAI source harvesting history",
                    body=oha.perform_request_viewhistoryday(oai_src_id=oai_src_id,
                                                    ln=ln,
                                                    year=int(year),
                                                    month=int(month),
                                                    day=int(day),
                                                    start=int(start)),
                    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)
コード例 #5
0
def viewholdingpen(req, filter_key="", ln=CFG_SITE_LANG):
    navtrail_previous_links = oha.getnavtrail(
    ) + """&gt; <a class="navtrail" href="%s/admin/oaiharvest/oaiharvestadmin.py">OAIHarvest Admin Interface</a> """ % (
        CFG_SITE_URL)
    try:
        uid = getUid(req)
    except Error as e:
        return page(title="OAIHarvest Admin Interface - Error",
                    body=e,
                    uid=uid,
                    language=ln,
                    navtrail=navtrail_previous_links,
                    lastupdated=__lastupdated__,
                    req=req)
    auth = check_user(req, 'cfgoaiharvest')
    if not auth[0]:
        return page(title="Holding Pen",
                    metaheaderadd=oha.view_holdingpen_headers(),
                    body=oha.perform_request_view_holdingpen_tree(filter_key),
                    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)
コード例 #6
0
ファイル: bibformatadmin.py プロジェクト: mhellmic/b2share
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)
コード例 #7
0
ファイル: bibformatadmin.py プロジェクト: mhellmic/b2share
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)
コード例 #8
0
ファイル: websearchadmin.py プロジェクト: mhellmic/b2share
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)
コード例 #9
0
ファイル: oaiharvestadmin.py プロジェクト: SCOAP3/invenio
def viewhistoryday(req, oai_src_id=0, ln=CFG_SITE_LANG, year=None, month=None, day=None, start=0):
    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)
    d_date = datetime.datetime.now()
    if year == None:
        year = d_date.year
    if month == None:
        month = d_date.month
    if day == None:
        day = d_date.day
    try:
        uid = getUid(req)
    except Error as e:
        return page(title="OAI Harvest Admin Interface - Error",
                    body=e,
                    uid=uid,
                    language=ln,
                    navtrail = navtrail_previous_links,
                    lastupdated=__lastupdated__,
                    req=req)
    auth = check_user(req,'cfgoaiharvest')
    if not auth[0]:
        return page(title="View OAI source harvesting history",
                    body=oha.perform_request_viewhistoryday(oai_src_id=oai_src_id,
                                                    ln=ln,
                                                    year=int(year),
                                                    month=int(month),
                                                    day=int(day),
                                                    start=int(start)),
                    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)
コード例 #10
0
ファイル: bibformatadmin.py プロジェクト: mhellmic/b2share
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)
コード例 #11
0
ファイル: bibformatadmin.py プロジェクト: mhellmic/b2share
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 %(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)
コード例 #12
0
ファイル: bibformatadmin.py プロジェクト: mhellmic/b2share
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)
コード例 #13
0
def delhprecord(req, ln=CFG_SITE_LANG, hpupdate_id=0):
    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 as e:
        return page(title="OAI Harvest Admin Interface - Error",
                    body=e,
                    uid=uid,
                    language=ln,
                    navtrail=navtrail_previous_links,
                    lastupdated=__lastupdated__,
                    req=req)
    auth = check_user(req, 'cfgoaiharvest')
    if not auth[0]:
        return page(title="Holding Pen Record",
                    body=oha.perform_request_delhprecord(
                        hpupdate_id=hpupdate_id, 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)
コード例 #14
0
ファイル: websearchadmin.py プロジェクト: chokribr/invenio-1
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)
コード例 #15
0
ファイル: websearchadmin.py プロジェクト: mhellmic/b2share
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)
コード例 #16
0
ファイル: websearchadmin.py プロジェクト: mhellmic/b2share
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__)
コード例 #17
0
ファイル: websearchadmin.py プロジェクト: mhellmic/b2share
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)
コード例 #18
0
ファイル: websearchadmin.py プロジェクト: mhellmic/b2share
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)
コード例 #19
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:
        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)
コード例 #20
0
def modifytranslations(req,
                       rnkID='',
                       ln=CFG_SITE_LANG,
                       sel_type='',
                       trans=[],
                       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:
        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)
コード例 #21
0
ファイル: oaiharvestadmin.py プロジェクト: SCOAP3/invenio
def testsource(req, oai_src_id=None, ln=CFG_SITE_LANG, record_id=None):
    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 as e:
        return page(title="OAI Harvest Admin Interface - Error",
                    body=e,
                    uid=uid,
                    language=ln,
                    navtrail = navtrail_previous_links,
                    lastupdated=__lastupdated__,
                    req=req)
    auth = check_user(req,'cfgoaiharvest')
    if not auth[0]:
        return page(title="Test OAI Source",
                    body=oha.perform_request_testsource(oai_src_id=oai_src_id,
                                                        ln=ln,
                                                        record_id=record_id),
                    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)
コード例 #22
0
def reharvest(req, oai_src_id=None, ln=CFG_SITE_LANG, **records):
    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 as e:
        return page(title="OAI Harvest Admin Interface - Error",
                    body=e,
                    uid=uid,
                    language=ln,
                    navtrail=navtrail_previous_links,
                    lastupdated=__lastupdated__,
                    req=req)
    auth = check_user(req, 'cfgoaiharvest')
    if not auth[0]:
        return page(title="OAI source - reharvesting records",
                    body=oha.perform_request_reharvest_records(
                        oai_src_id=oai_src_id, ln=ln, record_ids=records),
                    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)
コード例 #23
0
def preview_harvested_xml(req,
                          oai_src_id=None,
                          ln=CFG_SITE_LANG,
                          record_id=None):
    navtrail_previous_links = oha.getnavtrail(
    ) + """&gt; <a class="navtrail" href="%s/admin/oaiharvest/oaiharvestadmin.py">OAI Harvest Admin Interface</a> """ % (
        CFG_SITE_URL)
    try:
        uid = getUid(req)
    except Error as e:
        return page(title="OAI Harvest Admin Interface - Error",
                    body=e,
                    uid=uid,
                    language=ln,
                    navtrail=navtrail_previous_links,
                    lastupdated=__lastupdated__,
                    req=req)
    auth = check_user(req, 'cfgoaiharvest')
    if not auth[0]:
        if (record_id == None) or (oai_src_id == None):
            req.content_type = "text/plain"
            req.write("No record number provided")
            return
        content = oha.perform_request_preview_harvested_xml(
            oai_src_id, record_id)
        if content[0]:
            req.content_type = "text/xml"
        else:
            req.content_type = "text/plain"
        return content[1]
    else:
        return page_not_authorized(req=req,
                                   text=auth[1],
                                   navtrail=navtrail_previous_links)
コード例 #24
0
ファイル: oaiharvestadmin.py プロジェクト: SCOAP3/invenio
def viewentryhistory(req, oai_id=0, ln=CFG_SITE_LANG, start = 0):
    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 as e:
        return page(title="OAI Harvest Admin Interface - Error",
                    body=e,
                    uid=uid,
                    language=ln,
                    navtrail=navtrail_previous_links,
                    lastupdated=__lastupdated__,
                    req=req)
    auth = check_user(req,'cfgoaiharvest')
    if not auth[0]:
        return page(title="View OAI source harvesting history (single record)",
                    body=oha.perform_request_viewentryhistory(oai_id=str(oai_id),
                                                    ln=ln,
                                                    start=int(start)),
                    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)
コード例 #25
0
ファイル: webcommentadmin.py プロジェクト: SCOAP3/invenio
def users(req, ln=CFG_SITE_LANG):
    """
    View a list of all the users that have been reported, sorted by most reported
    @param req: request object to obtain user information
    @param ln: language
    """
    ln = wash_language(ln)
    _ = gettext_set_language(ln)
    navtrail_previous_links = getnavtrail()
    navtrail_previous_links += ' &gt; <a class="navtrail" href="%s/admin/webcomment/webcommentadmin.py/">' % CFG_SITE_URL
    navtrail_previous_links += _("WebComment Admin") + '</a>'

    try:
        uid = getUid(req)
    except Error:
        return page(title=_("Internal Error"),
                    body = create_error_box(req, verbose=0, ln=ln),
                    description="%s - Internal Error" % CFG_SITE_NAME,
                    keywords="%s, Internal Error" % CFG_SITE_NAME,
                    language=ln,
                    req=req)

    (auth_code, auth_msg) = check_user(req,'cfgwebcomment')
    if (auth_code != 'false'):
        return page(title=_("View all reported users"),
                    body=perform_request_users(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)
コード例 #26
0
ファイル: websearchadmin.py プロジェクト: chokribr/invenio-1
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)
コード例 #27
0
ファイル: oaiharvestadmin.py プロジェクト: SCOAP3/invenio
def index(req, ln=CFG_SITE_LANG):
    """Main OAI Harvest admin page"""
    navtrail_previous_links = oha.getnavtrail(ln=ln)

    try:
        uid = getUid(req)
    except Error as e:
        return page(title="OAI Harvest Admin Interface - Error",
                    body=e,
                    uid=uid,
                    language=ln,
                    navtrail=navtrail_previous_links,
                    lastupdated=__lastupdated__,
                    req=req)

    auth = check_user(req, 'cfgoaiharvest')
    if not auth[0]:
        return page(title="OAI Harvest Admin Interface",
                    body=oha.perform_request_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)
コード例 #28
0
ファイル: admin.py プロジェクト: mhellmic/b2share
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)
コード例 #29
0
ファイル: oaiharvestadmin.py プロジェクト: SCOAP3/invenio
def preview_harvested_xml(req, oai_src_id=None, ln=CFG_SITE_LANG, record_id=None):
    navtrail_previous_links = oha.getnavtrail() + """&gt; <a class="navtrail" href="%s/admin/oaiharvest/oaiharvestadmin.py">OAI Harvest Admin Interface</a> """ % (CFG_SITE_URL)
    try:
        uid = getUid(req)
    except Error as e:
        return page(title="OAI Harvest Admin Interface - Error",
                    body=e,
                    uid=uid,
                    language=ln,
                    navtrail = navtrail_previous_links,
                    lastupdated=__lastupdated__,
                    req=req)
    auth = check_user(req,'cfgoaiharvest')
    if not auth[0]:
        if (record_id == None) or (oai_src_id == None):
            req.content_type = "text/plain";
            req.write("No record number provided")
            return
        content = oha.perform_request_preview_harvested_xml(oai_src_id, record_id)
        if content[0]:
            req.content_type = "text/xml"
        else:
            req.content_type = "text/plain"
        return content[1]
    else:
        return page_not_authorized(req=req, text=auth[1], navtrail=navtrail_previous_links)
コード例 #30
0
ファイル: oaiharvestadmin.py プロジェクト: SCOAP3/invenio
def viewtasklogs(req, ln=CFG_SITE_LANG, task_id=0):
    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 as e:
        return page(title="OAI Harvest Admin Interface - Error",
                    body=e,
                    uid=uid,
                    language=ln,
                    navtrail=navtrail_previous_links,
                    lastupdated=__lastupdated__,
                    req=req)
    auth = check_user(req, 'cfgoaiharvest')
    if not auth[0]:
        # Page refreshes every minute
        return page(title="View bibsched task logs",
                    body=oha.perform_request_viewtasklogs(ln=ln,
                                                          task_id=int(task_id)),
                    uid=uid,
                    language=ln,
                    req=req,
                    navtrail=navtrail_previous_links,
                    lastupdated=__lastupdated__,
                    metaheaderadd='<meta http-equiv="refresh" content="60" />')
    else:
        return page_not_authorized(req=req, text=auth[1], navtrail=navtrail_previous_links)
コード例 #31
0
ファイル: webcommentadmin.py プロジェクト: SCOAP3/invenio
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 = getnavtrail()
    navtrail_previous_links +=' &gt; <a class="navtrail" href="%s/admin/webcomment/webcommentadmin.py/">' % CFG_SITE_URL
    navtrail_previous_links += _("WebComment Admin") + '</a>'

    try:
        uid = getUid(req)
    except Error:
        return page(title=_("Internal Error"),
                    body = create_error_box(req, verbose=0, ln=ln),
                    description="%s - Internal Error" % CFG_SITE_NAME,
                    keywords="%s, Internal Error" % CFG_SITE_NAME,
                    language=ln,
                    req=req)

    (auth_code, auth_msg) = check_user(req, 'cfgwebcomment')
    if (auth_code != 'false'):
        return page(title=_("WebComment Admin"),
                body=perform_request_index(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)
コード例 #32
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 = getnavtrail()
    navtrail_previous_links += ' &gt; <a class="navtrail" href="%s/admin/webcomment/webcommentadmin.py/">' % CFG_SITE_URL
    navtrail_previous_links += _("WebComment Admin") + '</a>'

    try:
        uid = getUid(req)
    except Error:
        return page(title=_("Internal Error"),
                    body=create_error_box(req, verbose=0, ln=ln),
                    description="%s - Internal Error" % CFG_SITE_NAME,
                    keywords="%s, Internal Error" % CFG_SITE_NAME,
                    language=ln,
                    req=req)

    (auth_code, auth_msg) = check_user(req, 'cfgwebcomment')
    if (auth_code != 'false'):
        return page(title=_("WebComment Admin"),
                    body=perform_request_index(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)
コード例 #33
0
def index(req, ln=CFG_SITE_LANG):
    """Main OAI Harvest admin page"""
    navtrail_previous_links = oha.getnavtrail(ln=ln)

    try:
        uid = getUid(req)
    except Error as e:
        return page(title="OAI Harvest Admin Interface - Error",
                    body=e,
                    uid=uid,
                    language=ln,
                    navtrail=navtrail_previous_links,
                    lastupdated=__lastupdated__,
                    req=req)

    auth = check_user(req, 'cfgoaiharvest')
    if not auth[0]:
        return page(title="OAI Harvest Admin Interface",
                    body=oha.perform_request_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)
コード例 #34
0
def viewtasklogs(req, ln=CFG_SITE_LANG, task_id=0):
    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 as e:
        return page(title="OAI Harvest Admin Interface - Error",
                    body=e,
                    uid=uid,
                    language=ln,
                    navtrail=navtrail_previous_links,
                    lastupdated=__lastupdated__,
                    req=req)
    auth = check_user(req, 'cfgoaiharvest')
    if not auth[0]:
        # Page refreshes every minute
        return page(title="View bibsched task logs",
                    body=oha.perform_request_viewtasklogs(
                        ln=ln, task_id=int(task_id)),
                    uid=uid,
                    language=ln,
                    req=req,
                    navtrail=navtrail_previous_links,
                    lastupdated=__lastupdated__,
                    metaheaderadd='<meta http-equiv="refresh" content="60" />')
    else:
        return page_not_authorized(req=req,
                                   text=auth[1],
                                   navtrail=navtrail_previous_links)
コード例 #35
0
def viewentryhistory(req, oai_id=0, ln=CFG_SITE_LANG, start=0):
    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 as e:
        return page(title="OAI Harvest Admin Interface - Error",
                    body=e,
                    uid=uid,
                    language=ln,
                    navtrail=navtrail_previous_links,
                    lastupdated=__lastupdated__,
                    req=req)
    auth = check_user(req, 'cfgoaiharvest')
    if not auth[0]:
        return page(title="View OAI source harvesting history (single record)",
                    body=oha.perform_request_viewentryhistory(
                        oai_id=str(oai_id), ln=ln, start=int(start)),
                    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)
コード例 #36
0
ファイル: admin.py プロジェクト: Theer108/invenio
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 = """ &gt; <a class="navtrail" href="%s/kb?ln=%s">%s</a> &gt; %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 = """ &gt; <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)
コード例 #37
0
ファイル: bibformatadmin.py プロジェクト: mhellmic/b2share
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 %(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)
コード例 #38
0
def del_com(req, ln=CFG_SITE_LANG, action="delete", **hidden):
    """
    private function
    Delete a comment
    @param req: request object to obtain user information
    @param ln: language
    @param **hidden: ids of comments to delete sent as individual variables comidX=on, where X is id
    """
    ln = wash_language(ln)
    action = wash_url_argument(action, 'str')
    _ = gettext_set_language(ln)
    navtrail_previous_links = getnavtrail()
    navtrail_previous_links += ' &gt; <a class="navtrail" href="%s/admin/webcomment/webcommentadmin.py/">' % CFG_SITE_URL
    navtrail_previous_links += _("WebComment Admin") + '</a>'

    try:
        uid = getUid(req)
    except Error:
        return page(title=_("Internal Error"),
                    body=create_error_box(req, verbose=0, ln=ln),
                    description="%s - Internal Error" % CFG_SITE_NAME,
                    keywords="%s, Internal Error" % CFG_SITE_NAME,
                    language=ln,
                    req=req)

    (auth_code, auth_msg) = check_user(req, 'cfgwebcomment')
    if (auth_code != 'false'):
        comIDs = []
        args = hidden.keys()
        for var in args:
            try:
                comIDs.append(int(var.split('comid')[1]))
            except:
                pass
        if action == 'delete':
            body = perform_request_del_com(ln=ln, comIDs=comIDs)
            title = _("Delete comments")
        elif action == 'unreport':
            body = suppress_abuse_report(ln=ln, comIDs=comIDs)
            title = _("Suppress abuse reports")
        elif action == 'undelete':
            body = perform_request_undel_com(ln=ln, comIDs=comIDs)
            title = _("Undelete comments")
        else:
            redirect_to_url(
                req,
                CFG_SITE_SECURE_URL + '/admin/webcomment/webcommentadmin.py')
        return page(title=title,
                    body=body,
                    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)
コード例 #39
0
ファイル: admin.py プロジェクト: Theer108/invenio
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 = """
         &gt; <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)
コード例 #40
0
ファイル: admin.py プロジェクト: chokribr/invenio-1
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 = '''
         &gt; <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)
コード例 #41
0
ファイル: admin.py プロジェクト: Theer108/invenio
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 = """ &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:
        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)
コード例 #42
0
ファイル: webcommentadmin.py プロジェクト: SCOAP3/invenio
def del_com(req, ln=CFG_SITE_LANG, action="delete", **hidden):
    """
    private function
    Delete a comment
    @param req: request object to obtain user information
    @param ln: language
    @param **hidden: ids of comments to delete sent as individual variables comidX=on, where X is id
    """
    ln = wash_language(ln)
    action = wash_url_argument(action, 'str')
    _ = gettext_set_language(ln)
    navtrail_previous_links = getnavtrail()
    navtrail_previous_links += ' &gt; <a class="navtrail" href="%s/admin/webcomment/webcommentadmin.py/">' % CFG_SITE_URL
    navtrail_previous_links += _("WebComment Admin") + '</a>'

    try:
        uid = getUid(req)
    except Error:
        return page(title=_("Internal Error"),
                    body = create_error_box(req, verbose=0, ln=ln),
                    description="%s - Internal Error" % CFG_SITE_NAME,
                    keywords="%s, Internal Error" % CFG_SITE_NAME,
                    language=ln,
                    req=req)

    (auth_code, auth_msg) = check_user(req,'cfgwebcomment')
    if (auth_code != 'false'):
        comIDs = []
        args = hidden.keys()
        for var in args:
            try:
                comIDs.append(int(var.split('comid')[1]))
            except:
                pass
        if action == 'delete':
            body = perform_request_del_com(ln=ln, comIDs=comIDs)
            title = _("Delete comments")
        elif action == 'unreport':
            body = suppress_abuse_report(ln=ln, comIDs=comIDs)
            title = _("Suppress abuse reports")
        elif action == 'undelete':
            body = perform_request_undel_com(ln=ln, comIDs=comIDs)
            title = _("Undelete comments")
        else:
            redirect_to_url(req, CFG_SITE_SECURE_URL + '/admin/webcomment/webcommentadmin.py')
        return page(title=title,
                    body=body,
                    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)
コード例 #43
0
ファイル: bibformatadmin.py プロジェクト: mhellmic/b2share
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_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)
コード例 #44
0
ファイル: admin.py プロジェクト: chokribr/invenio-1
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 = ''' &gt; <a class="navtrail" href="%s/kb?ln=%s">%s</a> &gt; %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 = ''' &gt; <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)
コード例 #45
0
def comments(req,
             ln=CFG_SITE_LANG,
             uid="",
             comid="",
             reviews=0,
             collection=""):
    """
    View reported comments, filter by either user or a specific comment (only one given at a time)
    @param req: request object to obtain user information
    @param ln: language
    @param uid: user id
    @param comid: comment id
    @param reviews: boolean enabled for reviews, disabled for comments
    @param collection: filter results by collection
    """
    ln = wash_language(ln)
    _ = gettext_set_language(ln)
    navtrail_previous_links = getnavtrail()
    navtrail_previous_links += ' &gt; <a class="navtrail" href="%s/admin/webcomment/webcommentadmin.py/">' % CFG_SITE_URL
    navtrail_previous_links += _("WebComment Admin") + '</a>'

    try:
        auid = getUid(req)
    except Error:
        return page(title=_("Internal Error"),
                    body=create_error_box(req, verbose=0, ln=ln),
                    description="%s - Internal Error" % CFG_SITE_NAME,
                    keywords="%s, Internal Error" % CFG_SITE_NAME,
                    language=ln,
                    req=req)

    (auth_code, auth_msg) = check_user(auid, 'cfgwebcomment')
    if (auth_code != 'false'):
        return page(
            title=(reviews == '0' and _("View all comments reported as abuse")
                   or _("View all reviews reported as abuse")),
            body=perform_request_comments(req,
                                          ln=ln,
                                          uid=uid,
                                          comID=comid,
                                          reviews=reviews,
                                          abuse=True,
                                          collection=collection),
            uid=auid,
            language=ln,
            navtrail=navtrail_previous_links,
            lastupdated=__lastupdated__,
            req=req)
    else:
        return page_not_authorized(req=req,
                                   text=auth_msg,
                                   navtrail=navtrail_previous_links)
コード例 #46
0
ファイル: bibcheckadmin.py プロジェクト: chokribr/invenio-1
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)
コード例 #47
0
ファイル: bibcheckadmin.py プロジェクト: SCOAP3/invenio
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)
コード例 #48
0
ファイル: admin.py プロジェクト: Theer108/invenio
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 = """ &gt; <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)
コード例 #49
0
ファイル: oaiharvestadmin.py プロジェクト: SCOAP3/invenio
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 !"
コード例 #50
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 !"
コード例 #51
0
ファイル: bibformatadmin.py プロジェクト: mhellmic/b2share
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(''' &gt; <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)
コード例 #52
0
ファイル: admin.py プロジェクト: chokribr/invenio-1
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_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)
コード例 #53
0
ファイル: bibformatadmin.py プロジェクト: mhellmic/b2share
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)
コード例 #54
0
def del_single_com_mod(req, ln=CFG_SITE_LANG, id=""):
    """
    Allow moderator to delete a single comment
    @param req: request object to obtain user information
    @param ln: language
    @param id: comment id
    """
    ln = wash_language(ln)
    user_info = collect_user_info(req)
    referer = user_info['referer']
    (auth_code, auth_msg) = check_user(req, 'cfgwebcomment')
    if (auth_code != 'false') or check_user_is_author(user_info['uid'], id):
        perform_request_del_single_com_mod(ln=ln, id=id)
        redirect_to_url(req, referer)
    else:
        return page_not_authorized(req=req, text=auth_msg)
コード例 #55
0
def unreport_com(req, ln=CFG_SITE_LANG, id=""):
    """
    Unreport a comment
    @param req: request object to obtain user information
    @param ln: language
    @param id: comment id
    """
    ln = wash_language(ln)
    user_info = collect_user_info(req)
    referer = user_info['referer']
    (auth_code, auth_msg) = check_user(req, 'cfgwebcomment')
    if (auth_code != 'false'):
        perform_request_unreport_single_com(ln=ln, id=id)
        redirect_to_url(req, referer)
    else:
        return page_not_authorized(req=req, text=auth_msg)
コード例 #56
0
ファイル: admin.py プロジェクト: chokribr/invenio-1
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 = ''' &gt; <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)
コード例 #57
0
def harvest(req,
            oai_src_id=None,
            ln=CFG_SITE_LANG,
            record_id=None,
            enable_reporting=None,
            confirm=0):
    form = dict(req.form)
    content = {
        'confirm': (int, confirm),
        'enable_reporting': (str, enable_reporting),
        '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 as e:
        return page(title="OAI Harvest Admin Interface - Error",
                    body=e,
                    uid=uid,
                    language=argd['ln'],
                    navtrail=navtrail_previous_links,
                    lastupdated=__lastupdated__,
                    req=req)
    auth = check_user(req, 'cfgoaiharvest')
    if not auth[0]:
        return page(title="OAI source - harvesting new records",
                    body=oha.perform_request_harvest_record(
                        oai_src_id=argd['oai_src_id'],
                        ln=argd['ln'],
                        record_id=argd['record_id'],
                        uid=uid,
                        confirm=argd['confirm'],
                        enable_reporting=argd['enable_reporting']),
                    uid=uid,
                    language=argd['ln'],
                    req=req,
                    navtrail=navtrail_previous_links,
                    lastupdated=__lastupdated__)
    else:
        return page_not_authorized(req=req,
                                   text=auth[1],
                                   navtrail=navtrail_previous_links)
コード例 #58
0
def delete(req, ln=CFG_SITE_LANG, comid="", recid="", uid="", reviews=""):
    """
    Delete a comment by giving its comment id
    @param req: request object to obtain user information
    @param ln: language
    @param comid: comment id
    @param recid: ID of the record containing the comment
    @param uid: id of the user
    @param reviews: boolean 1 if deleting a review, 0 if deleting a comment
    """
    ln = wash_language(ln)
    _ = gettext_set_language(ln)
    navtrail_previous_links = getnavtrail()
    navtrail_previous_links += ' &gt; <a class="navtrail" href="%s/admin/webcomment/webcommentadmin.py/">' % CFG_SITE_URL
    navtrail_previous_links += _("WebComment Admin") + '</a>'

    try:
        uid = getUid(req)
    except Error:
        return page(title=_("Internal Error"),
                    body=create_error_box(req, verbose=0, ln=ln),
                    description="%s - Internal Error" % CFG_SITE_NAME,
                    keywords="%s, Internal Error" % CFG_SITE_NAME,
                    language=ln,
                    req=req)

    (auth_code, auth_msg) = check_user(req, 'cfgwebcomment')
    if (auth_code != 'false'):
        body = perform_request_delete(ln=ln,
                                      comID=comid,
                                      recID=recid,
                                      uid=uid,
                                      reviews=reviews)
        return page(title=(reviews == '1' and _("Delete/Undelete Reviews")
                           or _("Delete/Undelete Comments")) +
                    _(" or Suppress abuse reports"),
                    body=body,
                    uid=uid,
                    language=ln,
                    navtrail=navtrail_previous_links,
                    req=req,
                    lastupdated=__lastupdated__)
    else:
        return page_not_authorized(req=req,
                                   text=auth_msg,
                                   navtrail=navtrail_previous_links)
コード例 #59
0
def getHoldingPenData(req, elementId):
    try:
        getUid(req)
    except Error:
        return "unauthorised access !"
    auth = check_user(req, 'cfgoaiharvest')
    if auth[0]:
        return "unauthorised access !"

    elements = elementId.split("_")
    resultHtml = None

    if len(elements) == 2:
        filter_key = elements[1]
        resultHtml = oha.perform_request_gethpyears(elements[0], filter_key)
    elif len(elements) == 3:
        # only the year is specified
        filter_key = elements[2]
        nodeYear = int(elements[1])
        resultHtml = oha.perform_request_gethpyear(elements[0], nodeYear,
                                                   filter_key)

    elif len(elements) == 4:
        # year and month specified
        nodeYear = int(elements[1])
        nodeMonth = int(elements[2])
        filter_key = elements[3]
        resultHtml = oha.perform_request_gethpmonth(elements[0], nodeYear,
                                                    nodeMonth, filter_key)

    elif len(elements) == 5:
        # year, month and day specified - returning the entries themselves
        nodeYear = int(elements[1])
        nodeMonth = int(elements[2])
        nodeDay = int(elements[3])
        filter_key = elements[4]
        daySize = get_holdingpen_day_size(nodeYear, nodeMonth, nodeDay,
                                          filter_key)
        urlFilter = urllib.quote(filter_key)
        resultHtml = oha.perform_request_gethpdayfragment(
            nodeYear, nodeMonth, nodeDay, daySize, 0, urlFilter)
    else:
        # nothing of the above. error
        resultHtml = "Wrong request"
    return json.dumps({"elementId": elementId, "html": resultHtml})
コード例 #60
0
def latest(req, ln=CFG_SITE_LANG, comments=1, top=10, collection=""):
    """
    View latest comments/reviews
    @param req: request object to obtain user information
    @param ln: language
    @param comments: boolean enabled for comments, disabled for reviews
    @param top: number of results to be shown
    @param collection: filter results by collection
    """
    ln = wash_language(ln)
    _ = gettext_set_language(ln)
    navtrail_previous_links = getnavtrail()
    navtrail_previous_links += ' &gt; <a class="navtrail" href="%s/admin/webcomment/webcommentadmin.py/">' % CFG_SITE_URL
    navtrail_previous_links += _("WebComment Admin") + '</a>'

    try:
        auid = getUid(req)
    except Error:
        return page(title=_("Internal Error"),
                    body=create_error_box(req, verbose=0, ln=ln),
                    description="%s - Internal Error" % CFG_SITE_NAME,
                    keywords="%s, Internal Error" % CFG_SITE_NAME,
                    language=ln,
                    req=req)

    (auth_code, auth_msg) = check_user(auid, 'cfgwebcomment')
    if (auth_code != 'false'):
        return page(
            title=(comments == '0' and _("View latest reviewed records")
                   or _("View latest commented records")),
            body=perform_request_latest(req=req,
                                        ln=ln,
                                        comments=comments,
                                        top=top,
                                        collection=collection),
            uid=auid,
            language=ln,
            navtrail=navtrail_previous_links,
            lastupdated=__lastupdated__,
            req=req)
    else:
        return page_not_authorized(req=req,
                                   text=auth_msg,
                                   navtrail=navtrail_previous_links)