예제 #1
0
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(
        ' &gt; <a class="navtrail" href="%s/admin/webjournal/webjournaladmin.py">WebJournal Admin</a> &gt; <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)
예제 #2
0
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(' &gt; <a class="navtrail" href="%s/admin/webjournal/webjournaladmin.py">WebJournal Admin</a> &gt; <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)
예제 #3
0
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(' &gt; <a class="navtrail" href="%s/admin/webjournal/webjournaladmin.py">WebJournal Admin</a> &gt; <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)
예제 #4
0
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(
        ' &gt; <a class="navtrail" href="%s/admin/webjournal/webjournaladmin.py">WebJournal Admin</a> &gt; <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)
예제 #5
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 !"
예제 #6
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 !"
예제 #7
0
def index(req, ln=CFG_SITE_LANG, journal_name=None, action=""):
    """
    Main administration page.

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

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

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

    try:
        journal_name = wash_journal_name(ln, journal_name)
        action = wash_url_argument(action, 'str')
    except InvenioWebJournalNoJournalOnServerError 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)
예제 #8
0
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(' &gt; <a class="navtrail" href="%s/admin/webjournal/webjournaladmin.py">WebJournal Admin</a>' % CFG_SITE_URL)
    else:
        navtrail_previous_links = wjn.getnavtrail(' &gt; <a class="navtrail" href="%s/admin/webjournal/webjournaladmin.py">WebJournal Admin</a> &gt; <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)
예제 #9
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)
예제 #10
0
def deleteindex(req, idxID, ln=CFG_SITE_LANG, confirm=0):
    navtrail_previous_links = bic.getnavtrail(
    ) + """&gt; <a class="navtrail" href="%s/admin/bibindex/bibindexadmin.py/index">Manage Indexes</a> """ % (
        CFG_SITE_URL)

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

    auth = bic.check_user(req, 'cfgbibindex')
    if not auth[0]:
        return page(title="Edit 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)
예제 #11
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)
예제 #12
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)
예제 #13
0
    def unsubscribe(self, req, form):
        """
        Unsubscribe current user from current discussion.
        """
        argd = wash_urlargd(form, {"referer": (str, None)})

        user_info = collect_user_info(req)
        uid = getUid(req)

        if isGuestUser(uid):
            cookie = mail_cookie_create_authorize_action(
                VIEWRESTRCOLL, {"collection": guess_primary_collection_of_a_record(self.recid)}
            )
            target = (
                CFG_SITE_SECURE_URL
                + "/youraccount/login"
                + make_canonical_urlargd(
                    {"action": cookie, "ln": argd["ln"], "referer": CFG_SITE_SECURE_URL + user_info["uri"]}, {}
                )
            )
            return redirect_to_url(req, target, norobot=True)

        success = unsubscribe_user_from_discussion(self.recid, uid)
        display_url = "%s/%s/%s/comments/display?subscribed=%s&ln=%s" % (
            CFG_SITE_SECURE_URL,
            CFG_SITE_RECORD,
            self.recid,
            str(-success),
            argd["ln"],
        )
        redirect_to_url(req, display_url)
예제 #14
0
def index(req, ln=CFG_SITE_LANG):
    navtrail_previous_links = ora.getnavtrail(ln=ln)

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

    auth = ora.check_user(req, 'cfgoairepository')
    if not auth[0]:

        return page(title="OAI Repository Admin Interface",
                body=ora.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)
예제 #15
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)
예제 #16
0
    def daemon(self, req, form):
        """ Display content of folders where the daemon will look into """
        argd = wash_urlargd(form, {})
        _ = gettext_set_language(argd['ln'])

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

        uid = getUid(req)
        body = batchuploader_templates.tmpl_display_menu(argd['ln'],
                                                         ref="daemon")
        body += batchuploader_templates.tmpl_daemon_content(
            argd['ln'], docs, metadata)
        title = _("Batch Uploader: Daemon monitor")
        return page(title=title,
                    body=body,
                    metaheaderadd=batchuploader_templates.tmpl_styles(),
                    uid=uid,
                    lastupdated=__lastupdated__,
                    req=req,
                    language=argd['ln'],
                    navmenuid="batchuploader")
예제 #17
0
def functionusage(req, funcname, ln=CFG_SITE_LANG):
    """View the usage cases (document-type and actions) in which a function is used.
       @param function: the function name
       @param ln: the language
       @return: a web page
    """

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

    (auth_code, auth_msg) = check_user(req, 'cfgwebsubmit')
    if not auth_code:
        ## user is authorised to use WebSubmit Admin:
        body = perform_request_function_usage(funcname)
        return page(title       = "WebSubmit Function Usage",
                    body        = body,
                    navtrail    = get_navtrail(ln),
                    uid         = uid,
                    lastupdated = __lastupdated__,
                    req         = req,
                    language    = ln)
    else:
        ## user is not authorised to use WebSubmit Admin:
        return page_not_authorized(req=req, text=auth_msg, navtrail=get_navtrail(ln))
예제 #18
0
    def metadata(self, req, form):
        """ Display Metadata file upload form """
        argd = wash_urlargd(
            form, {
                'filetype': (str, ""),
                'mode': (str, ""),
                'submit_date': (str, "yyyy-mm-dd"),
                'submit_time': (str, "hh:mm:ss"),
                'email_logs_to': (str, None)
            })
        _ = gettext_set_language(argd['ln'])

        not_authorized = user_authorization(req, argd['ln'])
        if not_authorized:
            return not_authorized
        uid = getUid(req)
        if argd['email_logs_to'] is None:
            argd['email_logs_to'] = get_email(uid)
        body = batchuploader_templates.tmpl_display_menu(argd['ln'],
                                                         ref="metadata")
        body += batchuploader_templates.tmpl_display_web_metaupload_form(
            argd['ln'], argd['filetype'], argd['mode'], argd['submit_date'],
            argd['submit_time'], argd['email_logs_to'])

        title = _("Metadata batch upload")
        return page(title=title,
                    body=body,
                    metaheaderadd=batchuploader_templates.tmpl_styles(),
                    uid=uid,
                    lastupdated=__lastupdated__,
                    req=req,
                    language=argd['ln'],
                    navmenuid="batchuploader")
예제 #19
0
    def history(self, req, form):
        """Display upload history of the current user"""
        argd = wash_urlargd(form, {})
        _ = gettext_set_language(argd['ln'])

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

        uid = getUid(req)
        body = batchuploader_templates.tmpl_display_menu(argd['ln'],
                                                         ref="history")
        body += batchuploader_templates.tmpl_upload_history(
            argd['ln'], uploaded_meta_files, uploaded_doc_files)
        title = _("Upload history")
        return page(title=title,
                    body=body,
                    metaheaderadd=batchuploader_templates.tmpl_styles(),
                    uid=uid,
                    lastupdated=__lastupdated__,
                    req=req,
                    language=argd['ln'],
                    navmenuid="batchuploader")
예제 #20
0
def addindex(req, ln=CFG_SITE_LANG, idxNAME='', callback="yes", confirm=-1):
    navtrail_previous_links = bic.getnavtrail(
    ) + """&gt; <a class="navtrail" href="%s/admin/bibindex/bibindexadmin.py/index">Manage Indexes</a> """ % (
        CFG_SITE_URL)

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

    auth = bic.check_user(req, 'cfgbibindex')
    if not auth[0]:
        return page(title="Manage Indexes",
                    body=bic.perform_addindex(ln=ln,
                                              idxNAME=idxNAME,
                                              callback=callback,
                                              confirm=confirm),
                    uid=uid,
                    language=ln,
                    navtrail=navtrail_previous_links,
                    req=req,
                    lastupdated=__lastupdated__)
    else:
        return page_not_authorized(req=req,
                                   text=auth[1],
                                   navtrail=navtrail_previous_links)
예제 #21
0
def modifyfieldtranslations(req,
                            fldID,
                            ln=CFG_SITE_LANG,
                            sel_type='',
                            trans=[],
                            confirm=-1):
    navtrail_previous_links = bic.getnavtrail(
    ) + """&gt; <a class="navtrail" href="%s/admin/bibindex/bibindexadmin.py/field">Manage logical fields</a> """ % (
        CFG_SITE_URL)

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

    auth = bic.check_user(req, 'cfgbibindex')
    if not auth[0]:
        return page(title="Edit Logical Field",
                    body=bic.perform_modifyfieldtranslations(fldID=fldID,
                                                             ln=ln,
                                                             sel_type=sel_type,
                                                             trans=trans,
                                                             confirm=confirm),
                    uid=uid,
                    language=ln,
                    req=req,
                    navtrail=navtrail_previous_links,
                    lastupdated=__lastupdated__)
    else:
        return page_not_authorized(req=req,
                                   text=auth[1],
                                   navtrail=navtrail_previous_links)
예제 #22
0
def showfieldoverview(req, ln=CFG_SITE_LANG, callback='yes', confirm=-1):
    navtrail_previous_links = bic.getnavtrail(
    ) + """&gt; <a class="navtrail" href="%s/admin/bibindex/bibindexadmin.py/field">Manage logical fields</a> """ % (
        CFG_SITE_URL)

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

    auth = bic.check_user(req, 'cfgbibindex')
    if not auth[0]:
        return page(title="Manage logical fields",
                    body=bic.perform_showfieldoverview(ln=ln,
                                                       callback=callback,
                                                       confirm=confirm),
                    uid=uid,
                    language=ln,
                    req=req,
                    navtrail=navtrail_previous_links,
                    lastupdated=__lastupdated__)
    else:
        return page_not_authorized(req=req,
                                   text=auth[1],
                                   navtrail=navtrail_previous_links)
예제 #23
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)
예제 #24
0
def doctyperemove(req, doctype="", doctypedelete="", doctypedeleteconfirm="", ln=CFG_SITE_LANG):
    """Delete a WebSubmit document-type.
    @param doctype: the unique id of the document type to be deleted
    @param ln: the interface language
    @return: HTML page.
    """

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

    (auth_code, auth_msg) = check_user(req, 'cfgwebsubmit')
    if not auth_code:
        ## user is authorised to use WebSubmit Admin:
        (title, body) = perform_request_remove_doctype(doctype=doctype,
                                                       doctypedelete=doctypedelete,
                                                       doctypedeleteconfirm=doctypedeleteconfirm)
        return page(title       = title,
                    body        = body,
                    navtrail    = get_navtrail(ln),
                    uid         = uid,
                    lastupdated = __lastupdated__,
                    req         = req,
                    language    = ln)
    else:
        ## user is not authorised to use WebSubmit Admin:
        return page_not_authorized(req=req, text=auth_msg, navtrail=get_navtrail(ln))
예제 #25
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)
예제 #26
0
def doctypeadd(req, doctype=None, doctypename=None, doctypedescr=None, clonefrom=None, doctypedetailscommit="", ln=CFG_SITE_LANG):
    """Add a new document type to WebSubmit"""
    ln = wash_language(ln)
    _ = gettext_set_language(ln)
    uid = getUid(req)

    (auth_code, auth_msg) = check_user(req, 'cfgwebsubmit')
    if not auth_code:
        ## user is authorised to use WebSubmit Admin:
        (title, body) = perform_request_add_doctype(doctype=doctype,
                                                                      doctypename=doctypename,
                                                                      doctypedescr=doctypedescr,
                                                                      clonefrom=clonefrom,
                                                                      doctypedetailscommit=doctypedetailscommit
                                                                      )

        return page(title       = title,
                    body        = body,
                    navtrail    = get_navtrail(ln),
                    uid         = uid,
                    lastupdated = __lastupdated__,
                    req         = req,
                    language    = ln)
    else:
        ## user is not authorised to use WebSubmit Admin:
        return page_not_authorized(req=req, text=auth_msg, navtrail=get_navtrail(ln))
예제 #27
0
    def sub(self, req, form):
        """DEPRECATED: /submit/sub is deprecated now, so raise email to the admin (but allow submission to continue anyway)"""
        args = wash_urlargd(form, {'password': (str, '')})
        uid = getUid(req)
        if uid == -1 or CFG_ACCESS_CONTROL_LEVEL_SITE >= 1:
            return page_not_authorized(req, "../sub/", navmenuid='submit')
        try:
            raise DeprecationWarning, 'submit/sub handler has been used. Please use submit/direct. e.g. "submit/sub?RN=123@SBIFOO" -> "submit/direct?RN=123&sub=SBIFOO"'
        except DeprecationWarning:
            register_exception(req=req, alert_admin=True)

        ln = args['ln']
        _ = gettext_set_language(ln)
        #DEMOBOO_RN=DEMO-BOOK-2008-001&ln=en&password=1223993532.26572%40APPDEMOBOO
        params = dict(form)
        password = args['password']
        if password:
            del params['password']
            if "@" in password:
                params['access'], params['sub'] = password.split('@', 1)
            else:
                params['sub'] = password
        else:
            args = str(req.args).split('@')
            if len(args) > 1:
                params = {'sub': args[-1]}
                args = '@'.join(args[:-1])
                params.update(cgi.parse_qs(args))
            else:
                return warning_page(_("Sorry, invalid URL..."), req, ln=ln)
        url = "%s/submit/direct?%s" % (CFG_SITE_SECURE_URL,
                                       urlencode(params, doseq=True))
        redirect_to_url(req, url)
예제 #28
0
def doctypeconfiguresubmissionpagespreview(req,
                                           doctype="",
                                           action="",
                                           pagenum="",
                                           ln=CFG_SITE_LANG):
    ln = wash_language(ln)
    _ = gettext_set_language(ln)
    uid = getUid(req)

    (auth_code, auth_msg) = check_user(req, 'cfgwebsubmit')
    if not auth_code:
        ## user is authorised to use WebSubmit Admin:
        (title, body) = perform_request_configure_doctype_submissionpage_preview(doctype=doctype,
                                                                                 action=action,
                                                                                 pagenum=pagenum)
        return page(title       = title,
                    body        = body,
                    navtrail    = get_navtrail(ln),
                    uid         = uid,
                    lastupdated = __lastupdated__,
                    req         = req,
                    language    = ln)

    else:
        ## user is not authorised to use WebSubmit Admin:
        return page_not_authorized(req=req, text=auth_msg, navtrail=get_navtrail(ln))
예제 #29
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)
예제 #30
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)
예제 #31
0
    def subscribe(self, req, form):
        """
        Subscribe current user to receive email notification when new
        comments are added to current discussion.
        """
        argd = wash_urlargd(form, {'referer': (str, None)})

        uid = getUid(req)

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

        success = subscribe_user_to_discussion(self.recid, uid)
        display_url = "%s/%s/%s/comments/display?subscribed=%s&ln=%s" % \
                      (CFG_SITE_SECURE_URL, CFG_SITE_RECORD, self.recid, str(success), argd['ln'])
        redirect_to_url(req, display_url)
예제 #32
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)
예제 #33
0
def index(req, c=CFG_SITE_NAME, ln=CFG_SITE_LANG):
    """Approval web Interface.
    GET params:

    """
    uid = getUid(req)
    (auth_code, auth_message) = acc_authorize_action(uid, 'submit')
    if auth_code > 0 or CFG_ACCESS_CONTROL_LEVEL_SITE >= 1:
        return page_not_authorized(req,
                                   "../approve.py/index",
                                   navmenuid='yourapprovals',
                                   text=auth_message)

    ln = wash_language(ln)
    _ = gettext_set_language(ln)
    args = wash_urlargd(req.form, {'access': (str, '')})
    if args['access'] == "":
        return warning_page(
            _("approve.py: cannot determine document reference"), req, ln)
    url_params = get_approval_url_parameters(args['access'])
    if not url_params:
        return warning_page(_("approve.py: cannot find document in database"),
                            req, ln)
    url_params['ln'] = ln
    url = "%s/submit/direct?%s" % (CFG_SITE_SECURE_URL,
                                   urllib.urlencode(url_params))
    redirect_to_url(req, url)
예제 #34
0
def switchtagscore(req, fldID, id_1, id_2, ln=CFG_SITE_LANG):
    navtrail_previous_links = bic.getnavtrail(
    ) + """&gt; <a class="navtrail" href="%s/admin/bibindex/bibindexadmin.py/field">Manage logical fields</a> """ % (
        CFG_SITE_URL)

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

    auth = bic.check_user(req, 'cfgbibindex')
    if not auth[0]:
        return page(title="Edit Logical Field",
                    body=bic.perform_switchtagscore(fldID=fldID,
                                                    id_1=id_1,
                                                    id_2=id_2,
                                                    ln=ln),
                    uid=uid,
                    language=ln,
                    req=req,
                    navtrail=navtrail_previous_links,
                    lastupdated=__lastupdated__)
    else:
        return page_not_authorized(req=req,
                                   text=auth[1],
                                   navtrail=navtrail_previous_links)
예제 #35
0
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)
예제 #36
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)
예제 #37
0
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)
예제 #38
0
    def check_authorization_moderatelinkbacks(self, req, argd):
        """
        Check if user has authorization moderate linkbacks
        @return if yes: nothing, if guest: login redirect, otherwise page_not_authorized
        """
        # Check authorization
        uid = getUid(req)
        user_info = collect_user_info(req)

        (auth_code, auth_msg) = acc_authorize_action(
            req,
            'moderatelinkbacks',
            collection=guess_primary_collection_of_a_record(self.recid))
        if auth_code and user_info['email'] == 'guest':
            # Ask to login
            target = CFG_SITE_SECURE_URL + '/youraccount/login' + \
                     make_canonical_urlargd({'ln': argd['ln'],
                                             'referer': CFG_SITE_URL + user_info['uri']}, {})
            return redirect_to_url(req, target)
        elif auth_code:
            return page_not_authorized(req,
                                       referer="../",
                                       uid=uid,
                                       text=auth_msg,
                                       ln=argd['ln'])
예제 #39
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)
예제 #40
0
파일: webpage.py 프로젝트: SCOAP3/invenio
def pageheaderonly(title, navtrail="", description="", keywords="", uid=0,
                   cdspageheaderadd="", language=CFG_SITE_LANG, req=None,
                   secure_page_p=0, verbose=1, navmenuid="admin",
                   navtrail_append_title_p=1, metaheaderadd="",
                   rssurl=CFG_SITE_URL+"/rss", body_css_classes=None):
    """Return just the beginning of page(), with full headers.
       Suitable for the search results page and any long-taking scripts."""
    if req is not None:
        if uid is None:
            uid = getUid(uid)
        secure_page_p = req.is_https() and 1 or 0
    return webstyle_templates.tmpl_pageheader(req,
                      ln = language,
                      headertitle = title,
                      description = description,
                      keywords = keywords,
                      metaheaderadd = metaheaderadd,
                      userinfobox = create_userinfobox_body(req, uid, language),
                      navtrailbox = create_navtrailbox_body(navtrail_append_title_p \
                                                            and title or '',
                                                            navtrail,
                                                            language=language),
                      uid = uid,
                      secure_page_p = secure_page_p,
                      pageheaderadd = cdspageheaderadd,
                      navmenuid = navmenuid,
                      rssurl = rssurl,
                      body_css_classes=body_css_classes)
예제 #41
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)
예제 #42
0
    def history(self, req, form):
        """Display upload history of the current user"""
        argd = wash_urlargd(form, {})
        _ = gettext_set_language(argd['ln'])

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

        uid = getUid(req)
        body = batchuploader_templates.tmpl_display_menu(argd['ln'],
                                                         ref="history")
        body += batchuploader_templates.tmpl_upload_history(argd['ln'],
                                                            uploaded_meta_files,
                                                            uploaded_doc_files)
        title = _("Upload history")
        return page(title = title,
                    body = body,
                    metaheaderadd = batchuploader_templates.tmpl_styles(),
                    uid = uid,
                    lastupdated = __lastupdated__,
                    req = req,
                    language = argd['ln'],
                    navmenuid = "batchuploader")
예제 #43
0
def touchset(req, oai_set_id=None, ln=CFG_SITE_LANG, func=0):
    navtrail_previous_links = ora.getnavtrail(' &gt; <a class="navtrail" href="%s/admin/oairepository/oairepositoryadmin.py?ln=%s">OAI Repository Admin Interface</a> ' % (CFG_SITE_URL, ln), ln=ln)

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

    auth = ora.check_user(req,'cfgoairepository')
    if not auth[0]:
        return page(title="Touch OAI Set",
                    body=ora.perform_request_touchset(oai_set_id=oai_set_id,
                                                    ln=ln,
                                                    func=func),
                    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)
예제 #44
0
    def daemon(self, req, form):
        """ Display content of folders where the daemon will look into """
        argd = wash_urlargd(form, {})
        _ = gettext_set_language(argd['ln'])

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

        uid = getUid(req)
        body = batchuploader_templates.tmpl_display_menu(argd['ln'],
                                                         ref="daemon")
        body += batchuploader_templates.tmpl_daemon_content(argd['ln'], docs,
                                                            metadata)
        title = _("Batch Uploader: Daemon monitor")
        return page(title = title,
                    body = body,
                    metaheaderadd = batchuploader_templates.tmpl_styles(),
                    uid = uid,
                    lastupdated = __lastupdated__,
                    req = req,
                    language = argd['ln'],
                    navmenuid = "batchuploader")
예제 #45
0
    def getattachedfile(self, req, form):
        """
        Returns a file uploaded to the submission 'drop box' by the
        CKEditor.
        """
        argd = wash_urlargd(form, {
            'file': (str, None),
            'type': (str, None),
            'uid': (int, 0)
        })

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

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

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

        # Send error 404 in all other cases
        return (apache.HTTP_NOT_FOUND)
예제 #46
0
    def metadata(self, req, form):
        """ Display Metadata file upload form """
        argd = wash_urlargd(form, { 'filetype': (str, ""),
                                    'mode': (str, ""),
                                    'submit_date': (str, "yyyy-mm-dd"),
                                    'submit_time': (str, "hh:mm:ss"),
                                    'email_logs_to': (str, None)})
        _ = gettext_set_language(argd['ln'])

        not_authorized = user_authorization(req, argd['ln'])
        if not_authorized:
            return not_authorized
        uid = getUid(req)
        if argd['email_logs_to'] is None:
            argd['email_logs_to'] = get_email(uid)
        body = batchuploader_templates.tmpl_display_menu(argd['ln'], ref="metadata")
        body += batchuploader_templates.tmpl_display_web_metaupload_form(argd['ln'],
                argd['filetype'], argd['mode'], argd['submit_date'],
                argd['submit_time'], argd['email_logs_to'])

        title = _("Metadata batch upload")
        return page(title = title,
                    body = body,
                    metaheaderadd = batchuploader_templates.tmpl_styles(),
                    uid = uid,
                    lastupdated = __lastupdated__,
                    req = req,
                    language = argd['ln'],
                    navmenuid = "batchuploader")
예제 #47
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)
예제 #48
0
def modifysynonymkb(req, idxID, ln=CFG_SITE_LANG, idxKB='', idxMATCH='', callback='yes', confirm=-1):
    navtrail_previous_links = bic.getnavtrail()
    navtrail_previous_links += """&gt; <a class="navtrail" href="%s/admin/bibindex/bibindexadmin.py/index">Manage Indexes</a>""" % (CFG_SITE_URL)

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

    auth = bic.check_user(req,'cfgbibindex')
    if not auth[0]:
        return page(title="Edit Index",
                    body=bic.perform_modifysynonymkb(idxID=idxID,
                                                     ln=ln,
                                                     idxKB=idxKB,
                                                     idxMATCH=idxMATCH,
                                                     callback=callback,
                                                     confirm=confirm),
                    uid=uid,
                    language=ln,
                    req=req,
                    navtrail = navtrail_previous_links,
                    lastupdated=__lastupdated__)
    else:
        return page_not_authorized(req=req, text=auth[1], navtrail=navtrail_previous_links)
예제 #49
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)
예제 #50
0
def touchset(req, oai_set_id=None, ln=CFG_SITE_LANG, func=0):
    navtrail_previous_links = ora.getnavtrail(
        ' &gt; <a class="navtrail" href="%s/admin/oairepository/oairepositoryadmin.py?ln=%s">OAI Repository Admin Interface</a> '
        % (CFG_SITE_URL, ln),
        ln=ln)

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

    auth = ora.check_user(req, 'cfgoairepository')
    if not auth[0]:
        return page(title="Touch OAI Set",
                    body=ora.perform_request_touchset(oai_set_id=oai_set_id,
                                                      ln=ln,
                                                      func=func),
                    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)
예제 #51
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)
예제 #52
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)
예제 #53
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)
예제 #54
0
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)
예제 #55
0
    def subscribe(self, req, form):
        """
        Subscribe current user to receive email notification when new
        comments are added to current discussion.
        """
        argd = wash_urlargd(form, {"referer": (str, None)})

        uid = getUid(req)

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

        success = subscribe_user_to_discussion(self.recid, uid)
        display_url = "%s/%s/%s/comments/display?subscribed=%s&ln=%s" % (
            CFG_SITE_SECURE_URL,
            CFG_SITE_RECORD,
            self.recid,
            str(success),
            argd["ln"],
        )
        redirect_to_url(req, display_url)
예제 #56
0
    def getattachedfile(self, req, form):
        """
        Returns a file uploaded to the submission 'drop box' by the
        CKEditor.
        """
        argd = wash_urlargd(form, {'file': (str, None),
                                   'type': (str, None),
                                   'uid': (int, 0)})

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

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

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

        # Send error 404 in all other cases
        return(apache.HTTP_NOT_FOUND)
예제 #57
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)
예제 #58
0
    def sub(self, req, form):
        """DEPRECATED: /submit/sub is deprecated now, so raise email to the admin (but allow submission to continue anyway)"""
        args = wash_urlargd(form, {'password': (str, '')})
        uid = getUid(req)
        if uid == -1 or CFG_ACCESS_CONTROL_LEVEL_SITE >= 1:
            return page_not_authorized(req, "../sub/",
                                       navmenuid='submit')
        try:
            raise DeprecationWarning, 'submit/sub handler has been used. Please use submit/direct. e.g. "submit/sub?RN=123@SBIFOO" -> "submit/direct?RN=123&sub=SBIFOO"'
        except DeprecationWarning:
            register_exception(req=req, alert_admin=True)

        ln = args['ln']
        _ = gettext_set_language(ln)
        #DEMOBOO_RN=DEMO-BOOK-2008-001&ln=en&password=1223993532.26572%40APPDEMOBOO
        params = dict(form)
        password = args['password']
        if password:
            del params['password']
            if "@" in password:
                params['access'], params['sub'] = password.split('@', 1)
            else:
                params['sub'] = password
        else:
            args = str(req.args).split('@')
            if len(args) > 1:
                params = {'sub' : args[-1]}
                args = '@'.join(args[:-1])
                params.update(cgi.parse_qs(args))
            else:
                return warning_page(_("Sorry, invalid URL..."), req, ln=ln)
        url = "%s/submit/direct?%s" % (CFG_SITE_SECURE_URL, urlencode(params, doseq=True))
        redirect_to_url(req, url)
예제 #59
0
def modifytag(req, fldID, tagID, ln=CFG_SITE_LANG, name='', value='', callback='yes', confirm=-1):
    navtrail_previous_links = bic.getnavtrail() + """&gt; <a class="navtrail" href="%s/admin/bibindex/bibindexadmin.py/field">Manage logical fields</a> """ % (CFG_SITE_URL)

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

    auth = bic.check_user(req,'cfgbibindex')
    if not auth[0]:
        return page(title="Edit Logical Field",
                    body=bic.perform_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)
예제 #60
0
def modifystopwords(req,
                    idxID,
                    ln=CFG_SITE_LANG,
                    idxSTOPWORDS='',
                    callback='yes',
                    confirm=-1):
    navtrail_previous_links = bic.getnavtrail()
    navtrail_previous_links += """&gt; <a class="navtrail" href="%s/admin/bibindex/bibindexadmin.py/index">Manage Indexes</a> """ % (
        CFG_SITE_URL)

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

    auth = bic.check_user(req, 'cfgbibindex')
    if not auth[0]:
        return page(title="Edit Index",
                    body=bic.perform_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)