Example #1
0
def editsource(req, **kwargs):
    form = dict(req.form)
    content = {'oai_src_id': (str, None),
               'oai_src_name': (str, ""),
               'oai_src_baseurl': (str, ""),
               'oai_src_prefix': (str, ""),
               'oai_src_comment': (str, ""),
               'oai_src_post': (list, None),
               'ln': (str, CFG_SITE_LANG),
               'confirm': (int, -1),
               'oai_src_sets': (list, None),
               'oai_src_workflow': (str, "")}
    # Grab list of defined post-process arguments to select from POST-data. e.g. ('c_cfg-file', str)
    post_arguments = [("%s_%s" % (mode[0], arg['name']), type(arg['value']))
                      for mode in CFG_OAI_POSSIBLE_POSTMODES
                      for arg in mode[2]]
    for argument_name, argument_type in post_arguments:
        if argument_type == str:
            content[argument_name] = (str, "")
        elif argument_type == list:
            content[argument_name] = (list, [])

    argd = wash_urlargd(form, content)
    oai_src_id = argd['oai_src_id']
    oai_src_name = argd['oai_src_name']
    oai_src_baseurl = argd['oai_src_baseurl']
    oai_src_prefix = argd['oai_src_prefix']
    oai_src_comment = argd['oai_src_comment']
    oai_src_workflow = argd['oai_src_workflow']
    oai_src_post = argd['oai_src_post']
    ln = argd['ln']
    confirm = argd['confirm']
    oai_src_sets = argd['oai_src_sets']
    if oai_src_sets is None:
        oai_src_sets = []

    oai_src_args = {}
    for argument_name, dummy in post_arguments:
        oai_src_args[argument_name] = argd[argument_name]

    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]:
        if isinstance(oai_src_sets, str):
            oai_src_sets = [oai_src_sets]
        return page(title="Edit OAI Source",
                    metaheaderadd=oha.getheader(),
                    body=oha.perform_request_editsource(oai_src_id=oai_src_id,
                                                        oai_src_name=oai_src_name,
                                                        oai_src_baseurl=oai_src_baseurl,
                                                        oai_src_prefix=oai_src_prefix,
                                                        oai_src_post=oai_src_post,
                                                        oai_src_sets=oai_src_sets,
                                                        oai_src_comment=oai_src_comment,
                                                        oai_src_args=oai_src_args,
                                                        oai_src_workflow=oai_src_workflow,
                                                        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)
Example #2
0
def editsource(req, **kwargs):
    form = dict(req.form)
    content = {
        'oai_src_id': (str, None),
        'oai_src_name': (str, ""),
        'oai_src_baseurl': (str, ""),
        'oai_src_prefix': (str, ""),
        'oai_src_comment': (str, ""),
        'oai_src_post': (list, None),
        'ln': (str, CFG_SITE_LANG),
        'confirm': (int, -1),
        'oai_src_sets': (list, None),
        'oai_src_workflow': (str, "")
    }
    # Grab list of defined post-process arguments to select from POST-data. e.g. ('c_cfg-file', str)
    post_arguments = [("%s_%s" % (mode[0], arg['name']), type(arg['value']))
                      for mode in CFG_OAI_POSSIBLE_POSTMODES
                      for arg in mode[2]]
    for argument_name, argument_type in post_arguments:
        if argument_type == str:
            content[argument_name] = (str, "")
        elif argument_type == list:
            content[argument_name] = (list, [])

    argd = wash_urlargd(form, content)
    oai_src_id = argd['oai_src_id']
    oai_src_name = argd['oai_src_name']
    oai_src_baseurl = argd['oai_src_baseurl']
    oai_src_prefix = argd['oai_src_prefix']
    oai_src_comment = argd['oai_src_comment']
    oai_src_workflow = argd['oai_src_workflow']
    oai_src_post = argd['oai_src_post']
    ln = argd['ln']
    confirm = argd['confirm']
    oai_src_sets = argd['oai_src_sets']
    if oai_src_sets is None:
        oai_src_sets = []

    oai_src_args = {}
    for argument_name, dummy in post_arguments:
        oai_src_args[argument_name] = argd[argument_name]

    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]:
        if isinstance(oai_src_sets, str):
            oai_src_sets = [oai_src_sets]
        return page(title="Edit OAI Source",
                    metaheaderadd=oha.getheader(),
                    body=oha.perform_request_editsource(
                        oai_src_id=oai_src_id,
                        oai_src_name=oai_src_name,
                        oai_src_baseurl=oai_src_baseurl,
                        oai_src_prefix=oai_src_prefix,
                        oai_src_post=oai_src_post,
                        oai_src_sets=oai_src_sets,
                        oai_src_comment=oai_src_comment,
                        oai_src_args=oai_src_args,
                        oai_src_workflow=oai_src_workflow,
                        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)
Example #3
0
def addsource(req, **kwargs):
    form = dict(req.form)
    content = {'ln': (str, "en"),
               'oai_src_name': (str, ""),
               'oai_src_baseurl': (str, ""),
               'oai_src_prefix': (str, ""),
               'oai_src_lastrun': (str, ""),
               'oai_src_comment': (str, ""),
               'oai_src_post': (list, None),
               'confirm': (int, -1),
               'oai_src_sets': (list, None),
               'oai_src_workflow': (str, "")}
    postmodes = _get_argd_postmodes()
    content.update(postmodes)
    argd = wash_urlargd(form, content)
    ln = argd['ln']
    oai_src_name = argd['oai_src_name']
    oai_src_baseurl = argd['oai_src_baseurl']
    oai_src_prefix = argd['oai_src_prefix']
    oai_src_lastrun = argd['oai_src_lastrun']
    oai_src_comment = argd['oai_src_comment']
    oai_src_post = argd['oai_src_post']
    confirm = argd['confirm']
    oai_src_sets = argd['oai_src_sets']
    oai_src_workflow = argd['oai_src_workflow']
    if oai_src_sets == None:
        oai_src_sets = []
    if oai_src_post == None:
        oai_src_post = []

    oai_src_args = {}
    for argument_name in postmodes:
        oai_src_args[argument_name] = argd[argument_name]

    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]:
        if isinstance(oai_src_sets, str):
            oai_src_sets = [oai_src_sets]
        return page(title="Add new OAI Source",
                    metaheaderadd=oha.getheader(),
                    body=oha.perform_request_addsource(oai_src_name=oai_src_name,
                                                       oai_src_baseurl=oai_src_baseurl,
                                                       oai_src_prefix=oai_src_prefix,
                                                       oai_src_lastrun=oai_src_lastrun,
                                                       oai_src_post=oai_src_post,
                                                       oai_src_sets=oai_src_sets,
                                                       oai_src_args=oai_src_args,
                                                       oai_src_workflow=oai_src_workflow,
                                                       oai_src_comment=oai_src_comment,
                                                       ln=ln,
                                                       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)