def getHoldingPenData(req, elementId):
    try:
        getUid(req)
    except Error:
        return "unauthorised access !"
    auth = check_user(req, 'cfgoaiharvest')
    if auth[0]:
        return "unauthorised access !"

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

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

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

    elif len(elements) == 5:
        # year, month and day specified - returning the entries themselves
        nodeYear = int(elements[1])
        nodeMonth = int(elements[2])
        nodeDay = int(elements[3])
        filter_key = elements[4]
        daySize = get_holdingpen_day_size(nodeYear, nodeMonth, nodeDay,
                                          filter_key)
        urlFilter = urllib.quote(filter_key)
        resultHtml = perform_request_gethpdayfragment(nodeYear, nodeMonth,
                                                      nodeDay, daySize, 0,
                                                      urlFilter)
    else:
        # nothing of the above. error
        resultHtml = "Wrong request"
    return json.dumps({"elementId": elementId, "html": resultHtml})
Beispiel #2
0
def getHoldingPenData(req, elementId):
    try:
        getUid(req)
    except Error:
        return "unauthorised access !"
    auth = check_user(req, 'cfgoaiharvest')
    if auth[0]:
        return "unauthorised access !"

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

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

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

    elif len(elements) == 5:
        # year, month and day specified - returning the entries themselves
        nodeYear = int(elements[1])
        nodeMonth = int(elements[2])
        nodeDay = int(elements[3])
        filter_key = elements[4]
        daySize = get_holdingpen_day_size(nodeYear, nodeMonth, nodeDay, filter_key)
        urlFilter = urllib.quote(filter_key)
        resultHtml = perform_request_gethpdayfragment(nodeYear, nodeMonth, nodeDay, daySize, 0, urlFilter)
    else:
        # nothing of the above. error
        resultHtml = "Wrong request"
    return json.dumps({"elementId": elementId, "html": resultHtml})
    if len(elements) == 2:
        filter = elements[1]
        resultHtml =  oha.perform_request_gethpyears(elements[0], filter);
    elif len(elements) == 3:
        # only the year is specified
        result = ""
        filter = elements[2]
        nodeYear = int(elements[1])
        resultHtml = oha.perform_request_gethpyear(elements[0], nodeYear, filter)

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

    elif len(elements) == 5:
        # year, month and day specified - returning the entries themselves
        nodeYear = int(elements[1])
        nodeMonth = int(elements[2])
        nodeDay = int(elements[3])
        filter = elements[4]
        daySize = get_holdingpen_day_size(nodeYear, nodeMonth, nodeDay, filter);
        resultHtml = """<li><div id="%s_pager"></div>&nbsp;</li>""" %(elementId,)
        resultsPerPage = 20
        numberOfPages = math.ceil(float(daySize) / resultsPerPage)
        pages = []
        urlFilter = urllib.quote(filter)
        for i in range(0, numberOfPages):
            pages += [
Beispiel #4
0
        filter = elements[1]
        resultHtml = oha.perform_request_gethpyears(elements[0], filter)
    elif len(elements) == 3:
        # only the year is specified
        result = ""
        filter = elements[2]
        nodeYear = int(elements[1])
        resultHtml = oha.perform_request_gethpyear(elements[0], nodeYear,
                                                   filter)

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

    elif len(elements) == 5:
        # year, month and day specified - returning the entries themselves
        nodeYear = int(elements[1])
        nodeMonth = int(elements[2])
        nodeDay = int(elements[3])
        filter = elements[4]
        daySize = get_holdingpen_day_size(nodeYear, nodeMonth, nodeDay, filter)
        resultHtml = """<li><div id="%s_pager"></div>&nbsp;</li>""" % (
            elementId, )
        resultsPerPage = 20
        numberOfPages = math.ceil(float(daySize) / resultsPerPage)
        pages = []
        urlFilter = urllib.quote(filter)
        for i in range(0, numberOfPages):
def getHoldingPenData(req, elementId):
    try:
        getUid(req)
    except Error:
        return "unauthorised access !"
    auth = check_user(req, 'cfgoaiharvest')
    if auth[0]:
        return "unauthorised access !"

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

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

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

    elif len(elements) == 5:
        # year, month and day specified - returning the entries themselves
        nodeYear = int(elements[1])
        nodeMonth = int(elements[2])
        nodeDay = int(elements[3])
        filter = elements[4]
        daySize = get_holdingpen_day_size(nodeYear, nodeMonth, nodeDay, filter)
        resultHtml = """<li><div id="%s_pager"></div>&nbsp;</li>""" % (
            elementId, )
        resultsPerPage = 20
        numberOfPages = math.ceil(float(daySize) / resultsPerPage)
        pages = []
        urlFilter = urllib.quote(filter)
        for i in range(0, numberOfPages):
            pages += [{
                "url":
                "%s/admin/oaiharvest/oaiharvestadmin.py/get_entries_fragment?year=%s&month=%s&day=%s&start=%i&limit=%i&filter=%s"
                % (CFG_SITE_URL, nodeYear, nodeMonth, nodeDay,
                   i * resultsPerPage, resultsPerPage, urlFilter),
                "selector":
                False,
                "type":
                "ajax",
            }]

        additionalData = {"pagerId": elementId + "_pager", "pages": pages}
    else:
        # nothing of the above. error
        resultHtml = "Wrong request"

    return json.dumps({
        "elementId": elementId,
        "html": resultHtml,
        "additionalData": additionalData
    })
Beispiel #6
0
def getHoldingPenData(req, elementId):
    try:
        getUid(req)
    except Error:
        return "unauthorised access !"
    auth = check_user(req, "cfgoaiharvest")
    if auth[0]:
        return "unauthorised access !"

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

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

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

    elif len(elements) == 5:
        # year, month and day specified - returning the entries themselves
        nodeYear = int(elements[1])
        nodeMonth = int(elements[2])
        nodeDay = int(elements[3])
        filter = elements[4]
        daySize = get_holdingpen_day_size(nodeYear, nodeMonth, nodeDay, filter)
        resultHtml = """<li><div id="%s_pager"></div>&nbsp;</li>""" % (elementId,)
        resultsPerPage = 20
        numberOfPages = math.ceil(float(daySize) / resultsPerPage)
        pages = []
        urlFilter = urllib.quote(filter)
        for i in range(0, numberOfPages):
            pages += [
                {
                    "baseurl": "%s/admin/oaiharvest/oaiharvestadmin.py/get_entries_fragment" % (CFG_SITE_URL,),
                    "selector": False,
                    "type": "ajax",
                    "year": nodeYear,
                    "month": nodeMonth,
                    "day": nodeDay,
                    "start": i * resultsPerPage,
                    "limit": resultsPerPage,
                    "filter": urlFilter,
                }
            ]

        additionalData = {"pagerId": elementId + "_pager", "pages": pages}
    else:
        # nothing of the above. error
        resultHtml = "Wrong request"

    return json.dumps({"elementId": elementId, "html": resultHtml, "additionalData": additionalData})