def make_copy_available(request_id):
    """
    Change the status of a copy for 'available' when
    an hold request was cancelled.

    @param request_id: identify the request: Primary key of crcLOANREQUEST
    @type request_id: int
    """

    barcode_requested = db.get_requested_barcode(request_id)
    db.update_item_status('available', barcode_requested)

    return
def make_copy_available(request_id):
    """
    Change the status of a copy for
    CFG_BIBCIRCULATION_ITEM_STATUS_ON_SHELF when
    an hold request was cancelled.

    @param request_id: identify the request: Primary key of crcLOANREQUEST
    @type request_id: int
    """

    barcode_requested = db.get_requested_barcode(request_id)
    db.update_item_status(CFG_BIBCIRCULATION_ITEM_STATUS_ON_SHELF, barcode_requested)
    update_requests_statuses(barcode_requested)
def make_copy_available(request_id):
    """
    Change the status of a copy for
    CFG_BIBCIRCULATION_ITEM_STATUS_ON_SHELF when
    an hold request was cancelled.

    @param request_id: identify the request: Primary key of crcLOANREQUEST
    @type request_id: int
    """

    barcode_requested = db.get_requested_barcode(request_id)
    db.update_item_status(CFG_BIBCIRCULATION_ITEM_STATUS_ON_SHELF, barcode_requested)
    update_requests_statuses(barcode_requested)
def make_copy_available(request_id):
    """
    Change the status of a copy for 'available' when
    an hold request was cancelled.

    @param request_id: identify the request: Primary key of crcLOANREQUEST
    @type request_id: int
    """

    barcode_requested = db.get_requested_barcode(request_id)
    db.update_item_status('available', barcode_requested)

    return
Beispiel #5
0
def update_request_data(request_id):
    """
    Update the status of a given request.

    @param request_id: identify the request: Primary key of crcLOANREQUEST
    @type request_id: int
    """

    barcode = db.get_request_barcode(request_id)
    is_on_loan = db.is_item_on_loan(barcode)

    if is_on_loan is not None:
        db.update_item_status(CFG_BIBCIRCULATION_ITEM_STATUS_ON_LOAN, barcode)
    else:
        db.update_item_status(CFG_BIBCIRCULATION_ITEM_STATUS_ON_SHELF, barcode)

    update_requests_statuses(barcode)

    return True
def update_request_data(request_id):
    """
    Update the status of a given request.

    @param request_id: identify the request: Primary key of crcLOANREQUEST
    @type request_id: int
    """

    barcode = db.get_request_barcode(request_id)
    is_on_loan = db.is_item_on_loan(barcode)

    if is_on_loan is not None:
        db.update_item_status(CFG_BIBCIRCULATION_ITEM_STATUS_ON_LOAN, barcode)
    else:
        db.update_item_status(CFG_BIBCIRCULATION_ITEM_STATUS_ON_SHELF, barcode)

    update_requests_statuses(barcode)

    return True
def update_request_data(request_id):
    """
    Update the status of a given request.

    @param request_id: identify the request: Primary key of crcLOANREQUEST
    @type request_id: int
    """

    barcode = db.get_request_barcode(request_id)
    nb_requests = db.get_number_requests_per_copy(barcode)
    is_on_loan = db.is_item_on_loan(barcode)

    if nb_requests == 0 and is_on_loan is not None:
        db.update_item_status('on loan', barcode)
    elif nb_requests == 0 and is_on_loan is None:
        db.update_item_status('available', barcode)
    else:
        db.update_item_status('requested', barcode)

    return
def update_request_data(request_id):
    """
    Update the status of a given request.

    @param request_id: identify the request: Primary key of crcLOANREQUEST
    @type request_id: int
    """

    barcode = db.get_request_barcode(request_id)
    nb_requests = db.get_number_requests_per_copy(barcode)
    is_on_loan = db.is_item_on_loan(barcode)

    if nb_requests == 0 and is_on_loan is not None:
        db.update_item_status('on loan', barcode)
    elif nb_requests == 0 and is_on_loan is None:
        db.update_item_status('available', barcode)
    else:
        db.update_item_status('requested', barcode)

    return
Beispiel #9
0
def perform_new_request_send(uid,
                             recid,
                             period_from,
                             period_to,
                             barcode,
                             ln=CFG_SITE_LANG):
    """
    @param recid: recID - Invenio record identifier
    @param ln: language of the page
    """

    nb_requests = db.get_number_requests_per_copy(barcode)
    is_on_loan = db.is_item_on_loan(barcode)

    if nb_requests == 0 and is_on_loan is not None:
        status = 'waiting'
    elif nb_requests == 0 and is_on_loan is None:
        status = 'pending'
    else:
        status = 'waiting'

    user = collect_user_info(uid)
    is_borrower = db.is_borrower(user['email'])

    if is_borrower != 0:
        address = db.get_borrower_address(user['email'])
        if address != 0:

            db.new_hold_request(is_borrower, recid, barcode, period_from,
                                period_to, status)

            is_on_loan = db.is_item_on_loan(barcode)

            db.update_item_status('requested', barcode)

            if not is_on_loan:
                send_email(fromaddr=CFG_BIBCIRCULATION_LIBRARIAN_EMAIL,
                           toaddr=CFG_SITE_SUPPORT_EMAIL,
                           subject='Hold request for books confirmation',
                           content=hold_request_mail(recid, is_borrower),
                           attempt_times=1,
                           attempt_sleeptime=10)
            if CFG_CERN_SITE == 1:
                message = bibcirculation_templates.tmpl_message_request_send_ok_cern(
                )
            else:
                message = bibcirculation_templates.tmpl_message_request_send_ok_other(
                )

        else:
            if CFG_CERN_SITE == 1:
                email = user['email']
                result = get_user_info_from_ldap(email)

                try:
                    ldap_address = result['physicalDeliveryOfficeName'][0]
                except KeyError:
                    ldap_address = None

                if ldap_address is not None:
                    db.add_borrower_address(ldap_address, email)

                    db.new_hold_request(is_borrower, recid, barcode,
                                        period_from, period_to, status)

                    db.update_item_status('requested', barcode)

                    send_email(fromaddr=CFG_BIBCIRCULATION_LIBRARIAN_EMAIL,
                               toaddr=CFG_SITE_SUPPORT_EMAIL,
                               subject='Hold request for books confirmation',
                               content=hold_request_mail(recid, is_borrower),
                               attempt_times=1,
                               attempt_sleeptime=10)

                    message = bibcirculation_templates.tmpl_message_request_send_ok_cern(
                        ln=ln)

                else:
                    message = bibcirculation_templates.tmpl_message_request_send_fail_cern(
                        ln=ln)

            else:
                message = bibcirculation_templates.tmpl_message_request_send_fail_other(
                    ln=ln)

    else:
        if CFG_CERN_SITE == 1:
            result = get_user_info_from_ldap(email=user['email'])

            try:
                name = result['cn'][0]
            except KeyError:
                name = None

            try:
                email = result['mail'][0]
            except KeyError:
                email = None

            try:
                phone = result['telephoneNumber'][0]
            except KeyError:
                phone = None

            try:
                address = result['physicalDeliveryOfficeName'][0]
            except KeyError:
                address = None

            try:
                mailbox = result['postOfficeBox'][0]
            except KeyError:
                mailbox = None

            if address is not None:
                db.new_borrower(name, email, phone, address, mailbox, '')

                is_borrower = db.is_borrower(email)

                db.new_hold_request(is_borrower, recid, barcode, period_from,
                                    period_to, status)

                db.update_item_status('requested', barcode)

                send_email(fromaddr=CFG_BIBCIRCULATION_LIBRARIAN_EMAIL,
                           toaddr=CFG_BIBCIRCULATION_LIBRARIAN_EMAIL,
                           subject='Hold request for books confirmation',
                           content=hold_request_mail(recid, is_borrower),
                           attempt_times=1,
                           attempt_sleeptime=10)
                message = bibcirculation_templates.tmpl_message_request_send_ok_cern(
                )

            else:
                message = bibcirculation_templates.tmpl_message_request_send_fail_cern(
                )

        else:
            message = bibcirculation_templates.tmpl_message_request_send_ok_other(
            )

    body = bibcirculation_templates.tmpl_new_request_send(message=message,
                                                          ln=ln)

    return body
Beispiel #10
0
def perform_new_request_send(uid, recid,
                             period_from, period_to,
                             barcode, ln=CFG_SITE_LANG):

    """
    @param recid: recID - Invenio record identifier
    @param ln: language of the page
    """

    nb_requests = db.get_number_requests_per_copy(barcode)
    is_on_loan = db.is_item_on_loan(barcode)

    if nb_requests == 0 and is_on_loan is not None:
        status = 'waiting'
    elif nb_requests == 0 and is_on_loan is None:
        status = 'pending'
    else:
        status = 'waiting'

    user = collect_user_info(uid)
    is_borrower = db.is_borrower(user['email'])

    if is_borrower != 0:
        address = db.get_borrower_address(user['email'])
        if address != 0:

            db.new_hold_request(is_borrower, recid, barcode,
                                period_from, period_to, status)

            is_on_loan=db.is_item_on_loan(barcode)

            db.update_item_status('requested', barcode)

            if not is_on_loan:
                send_email(fromaddr=CFG_BIBCIRCULATION_LIBRARIAN_EMAIL,
                       toaddr=CFG_SITE_SUPPORT_EMAIL,
                       subject='Hold request for books confirmation',
                       content=hold_request_mail(recid, is_borrower),
                       attempt_times=1,
                       attempt_sleeptime=10
                       )
            if CFG_CERN_SITE == 1:
                message = bibcirculation_templates.tmpl_message_request_send_ok_cern()
            else:
                message = bibcirculation_templates.tmpl_message_request_send_ok_other()

        else:
            if CFG_CERN_SITE == 1:
                email=user['email']
                result = get_user_info_from_ldap(email)

                try:
                    ldap_address = result['physicalDeliveryOfficeName'][0]
                except KeyError:
                    ldap_address = None

                if ldap_address is not None:
                    db.add_borrower_address(ldap_address, email)

                    db.new_hold_request(is_borrower, recid, barcode,
                                        period_from, period_to, status)

                    db.update_item_status('requested', barcode)

                    send_email(fromaddr=CFG_BIBCIRCULATION_LIBRARIAN_EMAIL,
                               toaddr=CFG_SITE_SUPPORT_EMAIL,
                               subject='Hold request for books confirmation',
                               content=hold_request_mail(recid, is_borrower),
                               attempt_times=1,
                               attempt_sleeptime=10
                               )

                    message = bibcirculation_templates.tmpl_message_request_send_ok_cern(ln=ln)

                else:
                    message = bibcirculation_templates.tmpl_message_request_send_fail_cern(ln=ln)

            else:
                message = bibcirculation_templates.tmpl_message_request_send_fail_other(ln=ln)


    else:
        if CFG_CERN_SITE == 1:
            result = get_user_info_from_ldap(email=user['email'])

            try:
                name = result['cn'][0]
            except KeyError:
                name = None

            try:
                email = result['mail'][0]
            except KeyError:
                email = None

            try:
                phone = result['telephoneNumber'][0]
            except KeyError:
                phone = None

            try:
                address = result['physicalDeliveryOfficeName'][0]
            except KeyError:
                address = None

            try:
                mailbox = result['postOfficeBox'][0]
            except KeyError:
                mailbox = None

            if address is not None:
                db.new_borrower(name, email, phone, address, mailbox, '')

                is_borrower = db.is_borrower(email)

                db.new_hold_request(is_borrower, recid, barcode,
                                    period_from, period_to, status)

                db.update_item_status('requested', barcode)

                send_email(fromaddr=CFG_BIBCIRCULATION_LIBRARIAN_EMAIL,
                           toaddr=CFG_BIBCIRCULATION_LIBRARIAN_EMAIL,
                           subject='Hold request for books confirmation',
                           content=hold_request_mail(recid, is_borrower),
                           attempt_times=1,
                           attempt_sleeptime=10
                           )
                message = bibcirculation_templates.tmpl_message_request_send_ok_cern()

            else:
                message = bibcirculation_templates.tmpl_message_request_send_fail_cern()

        else:
            message = bibcirculation_templates.tmpl_message_request_send_ok_other()

    body = bibcirculation_templates.tmpl_new_request_send(message=message, ln=ln)

    return body
def perform_new_request_send(
    uid, recid, from_year, from_month, from_day, to_year, to_month, to_day, barcode, ln=CFG_SITE_LANG
):

    """
    @param recid: recID - CDS Invenio record identifier
    @param ln: language of the page
    """

    request_from = get_datetext(from_year, from_month, from_day)
    request_to = get_datetext(to_year, to_month, to_day)

    nb_requests = db.get_number_requests_per_copy(barcode)
    is_on_loan = db.is_item_on_loan(barcode)

    if nb_requests == 0 and is_on_loan is not None:
        status = "waiting"
    elif nb_requests == 0 and is_on_loan is None:
        status = "pending"
    else:
        status = "waiting"

    user = collect_user_info(uid)
    is_borrower = db.is_borrower(user["email"])

    if is_borrower != 0:
        address = db.get_borrower_address(user["email"])
        if address != 0:

            db.new_hold_request(is_borrower, recid, barcode, request_from, request_to, status)
            db.update_item_status("requested", barcode)

            send_email(
                fromaddr=CFG_BIBCIRCULATION_LIBRARIAN_EMAIL,
                toaddr=CFG_SITE_SUPPORT_EMAIL,
                subject="Hold request for books confirmation",
                content=hold_request_mail(recid, is_borrower),
                attempt_times=1,
                attempt_sleeptime=10,
            )
            if CFG_CERN_SITE == 1:
                message = bibcirculation_templates.tmpl_message_request_send_ok_cern(ln=ln)
            else:
                message = bibcirculation_templates.tmpl_message_request_send_ok_other(ln=ln)

        else:
            if CFG_CERN_SITE == 1:
                email = user["email"]
                result = get_user_info_from_ldap(email)

                try:
                    ldap_address = result["physicalDeliveryOfficeName"][0]
                except KeyError:
                    ldap_address = None

                if ldap_address is not None:
                    db.add_borrower_address(ldap_address, email)

                    db.new_hold_request(is_borrower, recid, barcode, request_from, request_to, status)

                    db.update_item_status("requested", barcode)

                    send_email(
                        fromaddr=CFG_BIBCIRCULATION_LIBRARIAN_EMAIL,
                        toaddr=CFG_SITE_SUPPORT_EMAIL,
                        subject="Hold request for books confirmation",
                        content=hold_request_mail(recid, is_borrower),
                        attempt_times=1,
                        attempt_sleeptime=10,
                    )

                    message = bibcirculation_templates.tmpl_message_request_send_ok_cern(ln=ln)

                else:
                    message = bibcirculation_templates.tmpl_message_request_send_fail_cern(ln=ln)

            else:
                message = bibcirculation_templates.tmpl_message_request_send_fail_other(ln=ln)

    else:
        if CFG_CERN_SITE == 1:
            result = get_user_info_from_ldap(email=user["email"])

            try:
                name = result["cn"][0]
            except KeyError:
                name = None

            try:
                email = result["mail"][0]
            except KeyError:
                email = None

            try:
                phone = result["telephoneNumber"][0]
            except KeyError:
                phone = None

            try:
                address = result["physicalDeliveryOfficeName"][0]
            except KeyError:
                address = None

            try:
                mailbox = result["postOfficeBox"][0]
            except KeyError:
                mailbox = None

            if address is not None:
                db.new_borrower(name, email, phone, address, mailbox, "")

                is_borrower = db.is_borrower(email)

                db.new_hold_request(is_borrower, recid, barcode, request_from, request_to, status)

                db.update_item_status("requested", barcode)

                send_email(
                    fromaddr=CFG_BIBCIRCULATION_LIBRARIAN_EMAIL,
                    toaddr=CFG_SITE_SUPPORT_EMAIL,
                    subject="Hold request for books confirmation",
                    content=hold_request_mail(recid, is_borrower),
                    attempt_times=1,
                    attempt_sleeptime=10,
                )
                message = bibcirculation_templates.tmpl_message_request_send_ok_cern(ln=ln)

            else:
                message = bibcirculation_templates.tmpl_message_request_send_fail_cern(ln=ln)

        else:
            message = bibcirculation_templates.tmpl_message_request_send_ok_other(ln=ln)

    body = bibcirculation_templates.tmpl_new_request_send(message=message, ln=ln)

    return body