Пример #1
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)
Пример #2
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)
Пример #3
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)
Пример #4
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)
Пример #5
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)
Пример #6
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)
Пример #7
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)
Пример #8
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)
Пример #9
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)
Пример #10
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)
Пример #11
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)
Пример #12
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)
Пример #13
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)
Пример #14
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)
Пример #15
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)
Пример #16
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)
Пример #17
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)
Пример #18
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)
Пример #19
0
def editsource(req, oai_src_id=None, oai_src_name='', oai_src_baseurl='', oai_src_prefix='', oai_src_config='', oai_src_post='', ln=CFG_SITE_LANG, confirm=-1, oai_src_sets=[], oai_src_bibfilter=''):
    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",
                    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_config=oai_src_config,
                                                        oai_src_post=oai_src_post,
                                                        oai_src_sets=oai_src_sets,
                                                        oai_src_bibfilter=oai_src_bibfilter,
                                                        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)
Пример #20
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)
Пример #21
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)
Пример #22
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)