Example #1
0
def update_requests_statuses(barcode):

    recid = db.get_id_bibrec(barcode)
    description = db.get_item_description(barcode)

    list_of_pending_requests = db.get_requests(recid, description,
                                    CFG_BIBCIRCULATION_REQUEST_STATUS_PENDING)
    some_copy_available = False
    copies_status = db.get_copies_status(recid, description)
    if copies_status is not None:
        for status in copies_status:
            if status in (CFG_BIBCIRCULATION_ITEM_STATUS_ON_SHELF,
                          CFG_BIBCIRCULATION_ITEM_STATUS_IN_PROCESS):
                some_copy_available = True

    if len(list_of_pending_requests) == 1:
        if not some_copy_available:
            db.update_loan_request_status(CFG_BIBCIRCULATION_REQUEST_STATUS_WAITING,
                                          list_of_pending_requests[0][0])
        else:
            return list_of_pending_requests[0][0]

    elif len(list_of_pending_requests) == 0:
        if some_copy_available:
            list_of_waiting_requests = db.get_requests(recid, description,
                                    CFG_BIBCIRCULATION_REQUEST_STATUS_WAITING)
            if len(list_of_waiting_requests) > 0:
                db.update_loan_request_status(CFG_BIBCIRCULATION_REQUEST_STATUS_PENDING,
                                              list_of_waiting_requests[0][0])
                return list_of_waiting_requests[0][0]

    elif len(list_of_pending_requests) > 1:
        for request in list_of_pending_requests:
            db.update_loan_request_status(CFG_BIBCIRCULATION_REQUEST_STATUS_WAITING,
                                          request[0])
        list_of_waiting_requests = db.get_requests(recid, description,
                                    CFG_BIBCIRCULATION_REQUEST_STATUS_WAITING)
        if some_copy_available:
            db.update_loan_request_status(CFG_BIBCIRCULATION_REQUEST_STATUS_PENDING,
                                          list_of_waiting_requests[0][0])
            return list_of_waiting_requests[0][0]

    return None
Example #2
0
def update_requests_statuses(barcode):

    recid = db.get_id_bibrec(barcode)
    description = db.get_item_description(barcode)

    list_of_pending_requests = db.get_requests(recid, description,
                                    CFG_BIBCIRCULATION_REQUEST_STATUS_PENDING)
    some_copy_available = False
    copies_status = db.get_copies_status(recid, description)
    if copies_status is not None:
        for status in copies_status:
            if status in (CFG_BIBCIRCULATION_ITEM_STATUS_ON_SHELF,
                          CFG_BIBCIRCULATION_ITEM_STATUS_IN_PROCESS):
                some_copy_available = True

    if len(list_of_pending_requests) == 1:
        if not some_copy_available:
            db.update_loan_request_status(CFG_BIBCIRCULATION_REQUEST_STATUS_WAITING,
                                          list_of_pending_requests[0][0])
        else:
            return list_of_pending_requests[0][0]

    elif len(list_of_pending_requests) == 0:
        if some_copy_available:
            list_of_waiting_requests = db.get_requests(recid, description,
                                    CFG_BIBCIRCULATION_REQUEST_STATUS_WAITING)
            if len(list_of_waiting_requests) > 0:
                db.update_loan_request_status(CFG_BIBCIRCULATION_REQUEST_STATUS_PENDING,
                                              list_of_waiting_requests[0][0])
                return list_of_waiting_requests[0][0]

    elif len(list_of_pending_requests) > 1:
        for request in list_of_pending_requests:
            db.update_loan_request_status(CFG_BIBCIRCULATION_REQUEST_STATUS_WAITING,
                                          request[0])
        list_of_waiting_requests = db.get_requests(recid, description,
                                    CFG_BIBCIRCULATION_REQUEST_STATUS_WAITING)
        if some_copy_available:
            db.update_loan_request_status(CFG_BIBCIRCULATION_REQUEST_STATUS_PENDING,
                                          list_of_waiting_requests[0][0])
            return list_of_waiting_requests[0][0]

    return None
Example #3
0
def all_copies_are_missing(recid):
    """
    Verify if all copies of an item are missing

    @param recid: identify the record. Primary key of bibrec
    @type recid: int

    @return boolean
    """

    copies_status = db.get_copies_status(recid)
    number_of_missing = 0
    if copies_status == None:
        return True
    else:
        for (status) in copies_status:
            if status == 'missing':
                number_of_missing += 1

        if number_of_missing == len(copies_status):
            return True
        else:
            return False
Example #4
0
def all_copies_are_missing(recid):
    """
    Verify if all copies of an item are missing

    @param recid: identify the record. Primary key of bibrec
    @type recid: int

    @return boolean
    """

    copies_status = db.get_copies_status(recid)
    number_of_missing = 0
    if copies_status == None:
        return True
    else:
        for (status) in copies_status:
            if status == 'missing':
                number_of_missing += 1

        if number_of_missing == len(copies_status):
            return True
        else:
            return False