diff --git a/modules/bibcirculation/lib/bibcirculation.py b/modules/bibcirculation/lib/bibcirculation.py index b7f433051..37245ddb6 100644 --- a/modules/bibcirculation/lib/bibcirculation.py +++ b/modules/bibcirculation/lib/bibcirculation.py @@ -1,671 +1,672 @@ # -*- coding: utf-8 -*- ## ## This file is part of CDS Invenio. ## Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 CERN. ## ## CDS Invenio is free software; you can redistribute it and/or ## modify it under the terms of the GNU General Public License as ## published by the Free Software Foundation; either version 2 of the ## License, or (at your option) any later version. ## ## CDS Invenio is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with CDS Invenio; if not, write to the Free Software Foundation, Inc., ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. """BibCirculation ..........""" __revision__ = "$Id$" # bibcirculation imports import invenio.bibcirculation_dblayer as db import invenio.template bibcirculation_templates = invenio.template.load('bibcirculation') # others invenio imports from invenio.config import \ CFG_SITE_LANG, \ CFG_CERN_SITE, \ CFG_SITE_SUPPORT_EMAIL from invenio.dateutils import get_datetext import datetime from invenio.webuser import collect_user_info from invenio.mailutils import send_email from invenio.bibcirculation_utils import hold_request_mail, \ book_title_from_MARC, \ make_copy_available, \ create_ill_record #book_information_from_MARC from invenio.bibcirculation_cern_ldap import get_user_info_from_ldap -from invenio.bibcirculation_config import CFG_BIBCIRCULATION_LIBRARIAN_EMAIL +from invenio.bibcirculation_config import CFG_BIBCIRCULATION_LIBRARIAN_EMAIL, \ + CFG_BIBCIRCULATION_LOANS_EMAIL def perform_loanshistoricaloverview(uid, ln=CFG_SITE_LANG): """ Display Loans historical overview for user uid. @param uid: user id @param ln: language of the page @return body(html) """ invenio_user_email = db.get_invenio_user_email(uid) is_borrower = db.is_borrower(invenio_user_email) result = db.get_historical_overview(is_borrower) body = bibcirculation_templates.tmpl_loanshistoricaloverview(result=result, ln=ln) return body def perform_borrower_loans(uid, barcode, borrower_id, request_id, ln=CFG_SITE_LANG): """ Display all the loans and the requests of a given borrower. @param barcode: identify the item. Primary key of crcITEM. @type barcode: string @param borrower_id: identify the borrower. Primary key of crcBORROWER. @type borrower_id: int @param request_id: identify the request: Primary key of crcLOANREQUEST @type request_id: int @return body(html) """ infos = [] is_borrower = db.is_borrower(db.get_invenio_user_email(uid)) loans = db.get_borrower_loans(is_borrower) requests = db.get_borrower_requests(is_borrower) tmp_date = datetime.date.today() + datetime.timedelta(days=30) new_due_date = get_datetext(tmp_date.year, tmp_date.month, tmp_date.day) #renew loan if barcode: recid = db.get_id_bibrec(barcode) queue = db.get_queue_request(recid) if len(queue) != 0: infos.append("It is not possible to renew your loan for " \ "" + book_title_from_MARC(recid) + ". Another user " \ "is waiting for this book.") else: db.update_due_date(barcode, new_due_date) infos.append("Your loan has been renewed with sucess.") #cancel request if request_id: db.cancel_request(request_id, 'cancelled') make_copy_available(request_id) #renew all loans elif borrower_id: list_of_recids = db.get_borrower_recids(borrower_id) for (recid) in list_of_recids: queue = db.get_queue_request(recid[0]) #check if there are requests if len(queue) != 0: infos.append("It is not possible to renew your loan for " \ "" + book_title_from_MARC(recid) + ". Another user" \ " is waiting for this book.") else: db.update_due_date_borrower(borrower_id, new_due_date) infos.append("All loans have been renewed with success.") body = bibcirculation_templates.tmpl_yourloans(loans=loans, requests=requests, borrower_id=is_borrower, infos=infos, ln=ln) return body def perform_get_holdings_information(recid, req, ln=CFG_SITE_LANG): """ Display all the copies of an item. @param recid: identify the record. Primary key of bibrec. @type recid: int @return body(html) """ holdings_information = db.get_holdings_information(recid) body = bibcirculation_templates.tmpl_holdings_information2(recid=recid, req=req, holdings_info=holdings_information, ln=ln) return body def perform_get_pending_request(ln=CFG_SITE_LANG): """ @param ln: language of the page """ status = db.get_loan_request_by_status("pending") body = bibcirculation_templates.tmpl_get_pending_request(status=status, ln=ln) return body def perform_new_request(recid, barcode, ln=CFG_SITE_LANG): """ Display form to be filled by the user. @param uid: user id @type: int @param recid: identify the record. Primary key of bibrec. @type recid: int @param barcode: identify the item. Primary key of crcITEM. @type barcode: string @return request form """ body = bibcirculation_templates.tmpl_new_request2(recid=recid, barcode=barcode, ln=ln) return body def perform_new_request_send(uid, recid, period_from, period_to, barcode, ln=CFG_SITE_LANG): """ @param recid: recID - CDS 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, + toaddr=CFG_BIBCIRCULATION_LOANS_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, + toaddr=CFG_BIBCIRCULATION_LOANS_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 try: ccid = result['employeeID'][0] except KeyError: ccid = '' if address is not None: db.new_borrower(ccid, 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, + toaddr=CFG_BIBCIRCULATION_LOANS_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 ill_request_with_recid(recid, ln=CFG_SITE_LANG): """ Display ILL form. @param recid: identify the record. Primary key of bibrec. @type recid: int @param uid: user id @type: int """ body = bibcirculation_templates.tmpl_ill_request_with_recid(recid=recid, infos=[], ln=ln) return body #(title, year, authors, isbn, publisher) = book_information_from_MARC(int(recid)) #book_info = {'title': title, 'authors': authors, 'place': place, 'publisher': publisher, # 'year' : year, 'edition': edition, 'isbn' : isbn} def ill_register_request_with_recid(recid, uid, period_of_interest_from, period_of_interest_to, additional_comments, conditions, only_edition, ln=CFG_SITE_LANG): """ Register a new ILL request. @param recid: identify the record. Primary key of bibrec. @type recid: int @param uid: user id @type: int @param period_of_interest_from: period of interest - from(date) @type period_of_interest_from: string @param period_of_interest_to: period of interest - to(date) @type period_of_interest_to: string """ # create a dictionnary book_info = {'recid': recid} user = collect_user_info(uid) is_borrower = db.is_borrower(user['email']) if is_borrower == 0: 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 try: ccid = user_info['employeeID'][0] except KeyError: ccid = '' if address is not None: db.new_borrower(ccid, name, email, phone, address, mailbox, '') else: message = bibcirculation_templates.tmpl_message_request_send_fail_cern() else: message = bibcirculation_templates.tmpl_message_request_send_fail_other() return bibcirculation_templates.tmpl_ill_register_request_with_recid(message=message, ln=ln) address = db.get_borrower_address(user['email']) if address == 0: if CFG_CERN_SITE == 1: email=user['email'] result = get_user_info_from_ldap(email) try: address = result['physicalDeliveryOfficeName'][0] except KeyError: address = None if address is not None: db.add_borrower_address(address, email) else: message = bibcirculation_templates.tmpl_message_request_send_fail_cern() else: message = bibcirculation_templates.tmpl_message_request_send_fail_other() return bibcirculation_templates.tmpl_ill_register_request_with_recid(message=message, ln=ln) if not conditions: infos = [] infos.append("You didn't accept the ILL conditions.") return bibcirculation_templates.tmpl_ill_request_with_recid(recid, infos=infos, ln=ln) else: db.ill_register_request(book_info, is_borrower, period_of_interest_from, period_of_interest_to, 'new', additional_comments, only_edition or 'False','book') if CFG_CERN_SITE == 1: message = bibcirculation_templates.tmpl_message_request_send_ok_cern() else: message = bibcirculation_templates.tmpl_message_request_send_ok_other() #Notify librarian about new ILL request. send_email(fromaddr=CFG_BIBCIRCULATION_LIBRARIAN_EMAIL, - toaddr="piubrau@gmail.com", + toaddr=CFG_BIBCIRCULATION_LOANS_EMAIL, subject='ILL request for books confirmation', content=hold_request_mail(recid, is_borrower), attempt_times=1, attempt_sleeptime=10) return bibcirculation_templates.tmpl_ill_register_request_with_recid(message=message, ln=ln) def display_ill_form(ln=CFG_SITE_LANG): """ Display ILL form @param uid: user id @type: int """ body = bibcirculation_templates.tmpl_display_ill_form(infos=[], ln=ln) return body def ill_register_request(uid, title, authors, place, publisher, year, edition, isbn, period_of_interest_from, period_of_interest_to, additional_comments, conditions, only_edition, request_type, ln=CFG_SITE_LANG): """ Register new ILL request. Create new record (collection: ILL Books) @param uid: user id @type: int @param authors: book's authors @type authors: string @param place: place of publication @type place: string @param publisher: book's publisher @type publisher: string @param year: year of publication @type year: string @param edition: book's edition @type edition: string @param isbn: book's isbn @type isbn: string @param period_of_interest_from: period of interest - from(date) @type period_of_interest_from: string @param period_of_interest_to: period of interest - to(date) @type period_of_interest_to: string @param additional_comments: comments given by the user @type additional_comments: string @param conditions: ILL conditions @type conditions: boolean @param only_edition: borrower wants only the given edition @type only_edition: boolean """ item_info = (title, authors, place, publisher, year, edition, isbn) create_ill_record(item_info) book_info = {'title': title, 'authors': authors, 'place': place, 'publisher': publisher, 'year': year, 'edition': edition, 'isbn': isbn} user = collect_user_info(uid) is_borrower = db.is_borrower(user['email']) #Check if borrower is on DB. if is_borrower != 0: address = db.get_borrower_address(user['email']) #Check if borrower has an address. if address != 0: #Check if borrower has accepted ILL conditions. if conditions: #Register ILL request on crcILLREQUEST. db.ill_register_request(book_info, is_borrower, period_of_interest_from, period_of_interest_to, 'new', additional_comments, only_edition or 'False', request_type) #Display confirmation message. message = "Your ILL request has been registered and the " \ "document will be sent to you via internal mail." #Notify librarian about new ILL request. send_email(fromaddr=CFG_BIBCIRCULATION_LIBRARIAN_EMAIL, - toaddr=CFG_SITE_SUPPORT_EMAIL, + toaddr=CFG_BIBCIRCULATION_LOANS_EMAIL, subject='ILL request for books confirmation', content="", attempt_times=1, attempt_sleeptime=10 ) #Borrower did not accept ILL conditions. else: infos = [] infos.append("You didn't accept the ILL conditions.") body = bibcirculation_templates.tmpl_display_ill_form(infos=infos, ln=ln) #Borrower doesn't have an address. else: #If BibCirculation at CERN, use LDAP. 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 # verify address if ldap_address is not None: db.add_borrower_address(ldap_address, email) db.ill_register_request(book_info, is_borrower, period_of_interest_from, period_of_interest_to, 'new', additional_comments, only_edition or 'False', request_type) message = "Your ILL request has been registered and the document"\ " will be sent to you via internal mail." send_email(fromaddr=CFG_BIBCIRCULATION_LIBRARIAN_EMAIL, - toaddr=CFG_SITE_SUPPORT_EMAIL, + toaddr=CFG_BIBCIRCULATION_LOANS_EMAIL, subject='ILL request for books confirmation', content="", attempt_times=1, attempt_sleeptime=10 ) else: message = "It is not possible to validate your request. "\ "Your office address is not available. "\ "Please contact ... " else: # Get information from CERN LDAP 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 try: ccid = user_info['employeeID'][0] except KeyError: ccid = '' # verify address if address is not None: db.new_borrower(ccid,name, email, phone, address, mailbox, '') is_borrower = db.is_borrower(email) db.ill_register_request(book_info, is_borrower, period_of_interest_from, period_of_interest_to, 'new', additional_comments, only_edition or 'False', request_type) message = "Your ILL request has been registered and the document"\ " will be sent to you via internal mail." send_email(fromaddr=CFG_BIBCIRCULATION_LIBRARIAN_EMAIL, - toaddr=CFG_SITE_SUPPORT_EMAIL, + toaddr=CFG_BIBCIRCULATION_LOANS_EMAIL, subject='ILL request for books confirmation', content="", attempt_times=1, attempt_sleeptime=10 ) else: message = "It is not possible to validate your request. "\ "Your office address is not available."\ " Please contact ... " body = bibcirculation_templates.tmpl_ill_register_request_with_recid(message=message, ln=ln) return body diff --git a/modules/bibcirculation/lib/bibcirculation_config.py b/modules/bibcirculation/lib/bibcirculation_config.py index 51ab65f37..93682749b 100644 --- a/modules/bibcirculation/lib/bibcirculation_config.py +++ b/modules/bibcirculation/lib/bibcirculation_config.py @@ -1,202 +1,204 @@ # -*- coding: utf-8 -*- ## ## This file is part of CDS Invenio. ## Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 CERN. ## ## CDS Invenio is free software; you can redistribute it and/or ## modify it under the terms of the GNU General Public License as ## published by the Free Software Foundation; either version 2 of the ## License, or (at your option) any later version. ## ## CDS Invenio is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with CDS Invenio; if not, write to the Free Software Foundation, Inc., ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. """ bibcirculation config file """ __revision__ = "$Id$" from invenio.config import CFG_CERN_SITE, \ CFG_SITE_URL # templates used to notify borrowers if CFG_CERN_SITE == 1: CFG_BIBCIRCULATION_TEMPLATES = { 'OVERDUE': 'Overdue letter template (write some text)', 'REMINDER': 'Reminder letter template (write some text)', 'NOTIFICATION': 'Hello:\n'\ 'this is an automatic email for confirming the request for a book on behalf of:\n'\ '%s (ccid: %s, email: %s)\n'\ '%s (%s)\n\n'\ '\tTitle: %s\n'\ '\tAuthor: %s\n'\ '\tPublisher: %s\n'\ '\tYear: %s\n'\ '\tIsbn: %s\n\n'\ '\tLocation: %s\n'\ '\tLibrary: %s\n'\ '\t%s\n\n'\ '\tRequest date: %s\n\n'\ 'The document will be sent to you via internal mail.\n\n'\ 'Best regards\n', #user_name, ccid, user_email, address,department, mailbox, title, #author, publisher, year, isbn, location, library, #link_to_holdings_details, request_date 'SEND_RECALL': 'Dear Colleague,\n\n'\ 'The loan for the document(s)\n\n'\ 'Item information:\n\n'\ '\t title: %s \n'\ '\t year: %s \n'\ '\t author(s): %s \n'\ '\t isbn: %s \n'\ '\t publisher: %s \n\n'\ 'is overdue and another reader(s) is/are waiting for the document(s).'\ 'Please return them to the Library as soon as possible.'\ '\n\nBest regards', 'RECALL1': 'Dear Colleague,\n\n'\ 'The loan period has now expired for the following Library item which you'\ ' borrowed. Please return it to the Library (either personally or by'\ ' internal mail) or extend the loan at:\n\n'\ '%s/yourloans/display \n\n' % CFG_SITE_URL + 'If you have already done so, please ignore this message.\n\n'\ 'Item information:\n\n'\ '%s \n'\ '%s \n'\ '%s \n'\ '%s \n'\ '%s \n\n'\ 'Thank you for using our services, Library Staff \n\n\n\n'\ 'If you are not able to update your loans via WWW or for any other'\ ' matter concerning circulation of library material, please simply'\ ' reply to this mail.', 'RECALL2': 'Dear Colleague\n\n'\ 'The return date for the following Library item which you borrowed is now'\ 'well past. According to our records you have not responded to our first'\ 'recall message, so we now ask you to return the item to the Library'\ 'without delay (either personally or by internal mail). If you have already'\ 'done so, please ignore this message. To send any comments, reply to this'\ 'mail.\n\n' \ 'Item information:\n\n'\ '%s \n'\ '%s \n'\ '%s \n'\ '%s \n'\ '%s \n\n'\ 'Thank you in advance for your cooperation, CERN Library Staff', 'RECALL3': 'Dear Colleague,\n\n'\ 'We have already sent you two messages about the following Library item,'\ 'which should have been returned a long time ago. According to our records,'\ 'you have not responded to either of them. Please return the item to the'\ 'Library without delay (either personally or by internal mail) or reply to'\ 'this mail giving any comments. If we do not hear from you within one week,'\ 'I will feel free to take up the matter with your supervisor. If you have'\ 'already returned the item, please ignore this message.\n\n'\ 'Item information:\n\n'\ '%s \n'\ '%s \n'\ '%s \n'\ '%s \n'\ '%s \n\n'\ 'Thank you in advance for your cooperation, CERN Library Staff', 'EMPTY': 'Please choose one template' } else: CFG_BIBCIRCULATION_TEMPLATES = { 'OVERDUE': 'Overdue letter template (write some text)', 'REMINDER': 'Reminder letter template (write some text)', 'NOTIFICATION': 'Hello:\n'\ 'this is an automatic email for confirming the request for a book on behalf of:\n'\ '%s (ccid: %s, email: %s)\n'\ '%s (%s)\n\n'\ '\tTitle: %s\n'\ '\tAuthor: %s\n'\ '\tPublisher: %s\n'\ '\tYear: %s\n'\ '\tIsbn: %s\n\n'\ '\tLocation: %s\n'\ '\tLibrary: %s\n'\ '\t%s\n\n'\ '\tRequest date: %s\n\n'\ 'The document will be sent to you via internal mail.\n\n'\ 'Best regards\n', 'SEND_RECALL': 'Dear Colleague,\n\n'\ 'The loan for the document(s)\n\n'\ 'Item information:\n\n'\ '\t title: %s \n'\ '\t year: %s \n'\ '\t author(s): %s \n'\ '\t isbn: %s \n'\ '\t publisher: %s \n\n'\ 'is overdue and another reader(s) is/are waiting for the document(s).'\ 'Please return them to the Library as soon as possible.'\ '\n\nBest regards', 'RECALL1': 'Dear Colleague,\n\n'\ 'The loan period has now expired for the following Library item which you'\ ' borrowed. Please return it to the Library (either personally or by'\ ' internal mail) or extend the loan at:\n\n'\ '%s/yourloans/display \n\n' % CFG_SITE_URL + 'If you have already done so, please ignore this message.\n\n'\ 'Item information:\n\n'\ '\t title: %s \n'\ '\t year: %s \n'\ '\t author(s): %s \n'\ '\t isbn: %s \n'\ '\t publisher: %s \n\n'\ 'Thank you for using our services, Library Staff \n\n\n\n'\ 'If you are not able to update your loans via WWW or for any other'\ 'matter concerning circulation of library material, please simply'\ 'reply to this mail.', 'RECALL2': 'Dear Colleague\n\n'\ 'The return date for the following Library item which you borrowed is now'\ 'well past. According to our records you have not responded to our first'\ 'recall message, so we now ask you to return the item to the Library'\ 'without delay (either personally or by internal mail). If you have already'\ 'done so, please ignore this message. To send any comments, reply to this'\ 'mail.' \ 'Item information:\n\n'\ '%s \n'\ '%s \n'\ '%s \n'\ '%s \n'\ '%s \n\n'\ 'Thank you in advance for your cooperation, Library Staff', 'RECALL3': 'Dear Colleague,\n\n'\ 'We have already sent you two messages about the following Library item,'\ 'which should have been returned a long time ago. According to our records,'\ 'you have not responded to either of them. Please return the item to the'\ 'Library without delay (either personally or by internal mail) or reply to'\ 'this mail giving any comments. If we do not hear from you within one week,'\ 'I will feel free to take up the matter with your supervisor. If you have'\ 'already returned the item, please ignore this message.\n\n'\ 'Item information:\n\n'\ '%s \n'\ '%s \n'\ '%s \n'\ '%s \n'\ '%s \n\n'\ 'Thank you in advance for your cooperation, CERN Library Staff', 'EMPTY': 'Please choose one template' } CFG_BIBCIRCULATION_AMAZON_ACCESS_KEY = '1T6P3M3TDMW9HWJ212R2' if CFG_CERN_SITE == 1: CFG_BIBCIRCULATION_OVERDUE_LETTER_SENDER = 'CERN Library' CFG_BIBCIRCULATION_LIBRARIAN_EMAIL = 'CERN Library' + CFG_BIBCIRCULATION_LOANS_EMAIL = 'lib.loans@cern.ch' else: CFG_BIBCIRCULATION_OVERDUE_LETTER_SENDER = 'Atlantis Library' - CFG_BIBCIRCULATION_LIBRARIAN_EMAIL = 'Atlantis Library' + CFG_BIBCIRCULATION_LIBRARIAN_EMAIL = 'jaime.garcia.llopis@cern.ch' + CFG_BIBCIRCULATION_LOANS_EMAIL = CFG_BIBCIRCULATION_LIBRARIAN_EMAIL CFG_BIBCIRCULATION_HOLIDAYS = ['2009-07-09'] CFG_BIBCIRCULATION_WORKING_DAYS = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday'] diff --git a/modules/bibcirculation/lib/bibcirculation_daemon.py b/modules/bibcirculation/lib/bibcirculation_daemon.py index 174b0223c..8d852f45d 100644 --- a/modules/bibcirculation/lib/bibcirculation_daemon.py +++ b/modules/bibcirculation/lib/bibcirculation_daemon.py @@ -1,190 +1,186 @@ # -*- coding: utf-8 -*- ## ## This file is part of CDS Invenio. ## Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 CERN. ## ## CDS Invenio is free software; you can redistribute it and/or ## modify it under the terms of the GNU General Public License as ## published by the Free Software Foundation; either version 2 of the ## License, or (at your option) any later version. ## ## CDS Invenio is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with CDS Invenio; if not, write to the Free Software Foundation, Inc., ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. """ BibCirculation daemon. """ __revision__ = "$Id$" import sys import datetime import time from invenio.dbquery import run_sql from invenio.bibtask import task_init from invenio.mailutils import send_email import invenio.bibcirculation_dblayer as db from invenio.bibcirculation_config import CFG_BIBCIRCULATION_TEMPLATES, \ CFG_BIBCIRCULATION_LIBRARIAN_EMAIL from invenio.search_engine import get_fieldvalues from invenio.bibcirculation_utils import generate_email_body def get_expired_loan(): """ @return all expired loans """ res = run_sql("""select id_crcBORROWER, id, id_bibrec from crcLOAN where (status = 'on loan' and due_date < NOW()) or (status='expired') """) return res def update_expired_loan(loan_id): """ Update status, number of overdue letter and date of overdue letter @param loan_id: identify the loan. Primary key of crcLOAN. @type loan_id: int """ run_sql("""update crcLOAN set overdue_letter_number = overdue_letter_number + 1, status = 'expired', overdue_letter_date = NOW() where id = %s """, (loan_id, )) def get_overdue_letters_info(loan_id): """ Get the number of letters and the date of the last letter sent for a given loan_id. @param loan_id: identify the loan. Primary of crcLOAN. @type loan_id: int @return number_of_letters and date of the last letter """ res = run_sql("""select overdue_letter_number, DATE_FORMAT(overdue_letter_date,'%%Y-%%m-%%d') from crcLOAN where id=%s""", (loan_id, )) return res[0] def send_overdue_letter(borrower_id, subject, content): """ Send an overdue letter @param borrower_id: identify the borrower. Primary key of crcBORROWER. @type borrower_id: int @param subject: subject of the overdue letter @type subject: string """ to_borrower = db.get_borrower_email(borrower_id) send_email(fromaddr=CFG_BIBCIRCULATION_LIBRARIAN_EMAIL, toaddr=to_borrower, subject=subject, content=content, header='', footer='', attempt_times=1, attempt_sleeptime=10 ) return 1 def must_send_second_recall(date_letters): """ @param date_letters: date of the last letter. @type date_letters: string @return boolean """ today = datetime.date.today() time_tuple = time.strptime(date_letters, "%Y-%m-%d") #datetime.strptime(date_letters, "%Y-%m-%d") doesn't work (only on 2.5). tmp_date = datetime.datetime(*time_tuple[0:3]) + datetime.timedelta(weeks=1) if tmp_date.strftime("%Y-%m-%d") == today.strftime("%Y-%m-%d"): return True else: return False def must_send_third_recall(date_letters): """ @param date_letters: date of the last letter. @type date_letters: string @return boolean """ today = datetime.date.today() time_tuple = time.strptime(date_letters, "%Y-%m-%d") #datetime.strptime(date_letters, "%Y-%m-%d") doesn't work (only on 2.5). tmp_date = datetime.datetime(*time_tuple[0:3]) + datetime.timedelta(days=3) if tmp_date.strftime("%Y-%m-%d") == today.strftime("%Y-%m-%d"): return True else: return False def task_run_core(): """ run daemon """ - #write_message("Getting expired loans ...", verbose=9) expired_loans = get_expired_loan() for (borrower_id, loan_id, recid) in expired_loans: (number_of_letters, date_letters) = get_overdue_letters_info(loan_id) if number_of_letters == 0: content = generate_email_body(CFG_BIBCIRCULATION_TEMPLATES['RECALL1'], loan_id) elif number_of_letters == 1 and must_send_second_recall(date_letters): content = generate_email_body(CFG_BIBCIRCULATION_TEMPLATES['RECALL2'], loan_id) elif number_of_letters == 2 and must_send_third_recall(date_letters): content = generate_email_body(CFG_BIBCIRCULATION_TEMPLATES['RECALL3'], loan_id) elif must_send_third_recall(date_letters): content = generate_email_body(CFG_BIBCIRCULATION_TEMPLATES['RECALL3'], loan_id) title = ''.join(get_fieldvalues(recid, "245__a")) subject = "LOAN RECALL: " + title update_expired_loan(loan_id) - #write_message("Updating information about expired loans") - send_overdue_letter(borrower_id, subject, content) - #write_message("Sending overdue letter") - #write_message("Done!!") + send_overdue_letter(borrower_id, subject, content) return 1 def main(): """ main() """ task_init(authorization_action='runbibcirculation', authorization_msg="BibCirculation Task Submission", description="""Examples: %s -u admin """ % (sys.argv[0],), version=__revision__, task_run_fnc = task_run_core) if __name__ == '__main__': main() diff --git a/modules/bibcirculation/lib/bibcirculation_templates.py b/modules/bibcirculation/lib/bibcirculation_templates.py index 920c2cc7d..87daa36a1 100644 --- a/modules/bibcirculation/lib/bibcirculation_templates.py +++ b/modules/bibcirculation/lib/bibcirculation_templates.py @@ -1,16892 +1,16892 @@ # -*- coding: utf-8 -*- ## ## This file is part of CDS Invenio. ## Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 CERN. ## ## CDS Invenio is free software; you can redistribute it and/or ## modify it under the terms of the GNU General Public License as ## published by the Free Software Foundation; either version 2 of the ## License, or (at your option) any later version. ## ## CDS Invenio is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with CDS Invenio; if not, write to the Free Software Foundation, Inc., ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. """ Templates for bibcirculation module """ __revision__ = "$Id$" import datetime import time import cgi from invenio.urlutils import create_html_link from invenio.config import CFG_SITE_URL, CFG_SITE_LANG, \ CFG_CERN_SITE, CFG_SITE_SECURE_URL from invenio.bibcirculation_config import CFG_BIBCIRCULATION_LIBRARIAN_EMAIL from invenio.messages import gettext_set_language import invenio.bibcirculation_dblayer as db from invenio.bibcirculation_utils import get_book_cover, \ book_information_from_MARC, \ book_title_from_MARC, \ renew_loan_for_X_days, \ get_item_info_for_search_result, \ all_copies_are_missing, \ has_copies _MENU_ = """ -
+
""" % {'url': CFG_SITE_URL} class Template: """Templates for BibCirculation module""" def tmpl_infobox(self, infos, ln=CFG_SITE_LANG): """ Display len(infos) information fields @param infos: list of strings @param ln: language @return html output """ _ = gettext_set_language(ln) if not((type(infos) is list) or (type(infos) is tuple)): infos = [infos] infobox = "" for info in infos: infobox += "
" lines = info.split("\n") for line in lines[0:-1]: infobox += line + "
\n" infobox += lines[-1] + "

\n" return infobox def tmpl_holdings_information2(self, recid, req, holdings_info, ln=CFG_SITE_LANG): """ This template is used in the user interface. In this template it is possible to see all details (loan period, number of copies, location, etc) about a book. @param recid: identify the record. Primary key of bibrec. @type recid: int @param holdings_info: book's information (all copies) @type holdings_info: list """ _ = gettext_set_language(ln) if not book_title_from_MARC(recid): out = """
This record does not exist.
""" return out elif not has_copies(recid): out = """
This record has no copies.
""" return out # verify if all copies are missing elif all_copies_are_missing(recid): ill_link = """ILL services""" % (CFG_SITE_URL, recid) out = """
All the copies of %s are missing.You can request a copy using %s.
""" % (book_title_from_MARC(recid), ill_link) return out # verify if there are no copies elif not holdings_info: out = """
This item has no holdings.
""" return out out = """ """ out += """ """ % (_("Options"), _("Library"), _("Collection"), _("Location"), _("Description"), _("Loan period"), _("Status"), _("Due date"), _("Barcode")) for (barcode, library, collection, location, description, loan_period, status, due_date) in holdings_info: if status == 'Not for loan': request_button = '-' else: request_button = """""" % (CFG_SITE_URL, recid, barcode, _("Request")) if status == 'missing': out += """ """ else: out += """ """ % (request_button, library, collection or '-', location, description or '-', loan_period, status, due_date or '-', barcode) from invenio.bibcirculationadminlib import is_adminuser (auth_code, _auth_message) = is_adminuser(req) if auth_code != 0: bibcirc_link = '' else: bibcirc_link = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/get_item_details', {'recid': recid, 'ln': ln}, _("See this book on BibCirculation")) out += """
%s %s %s %s %s %s %s %s %s
%s %s %s %s %s %s %s %s %s


%s
""" % (bibcirc_link) return out def tmpl_book_not_for_loan(self): message = """
This item is not for loan.
""" return message def tmpl_message_sever_busy(self,ln): _ = gettext_set_language(ln) message = _('Server busy. Please, try again in a few seconds.') return message def tmpl_message_request_send_ok_cern(self): message = "Your request has been registered and the document"\ " will be sent to you via internal mail." return message def tmpl_message_request_send_ok_other(self): message = "Your request has been registered." return message def tmpl_message_request_send_fail_cern(self): message = "It is not possible to validate your request. "\ "Your office address is not available. "\ "Please contact " + CFG_BIBCIRCULATION_LIBRARIAN_EMAIL return message def tmpl_message_request_send_fail_other(self): message = "It is not possible to validate your request. "\ "Your office address is not available. "\ "Please contact " + CFG_BIBCIRCULATION_LIBRARIAN_EMAIL return message def tmpl_borrower_search_result(self, result, redirect='no', ln=CFG_SITE_LANG): """ When the admin features 'borrower_seach' is used, this template show the result. @param result: search result @type result:list @param ln: language """ _ = gettext_set_language(ln) out = """ """ out += _MENU_ if len(result) == 0: out += """

%s

""" % (_("0 borrowers found. Search by CCID.")) else: out += """

%s borrower(s) found

""" % (len(result), _("Borrower(s)")) for (borrower_id, name) in result: if redirect == 'no': borrower_link = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/get_borrower_details', {'borrower_id': borrower_id, 'ln': ln}, (name)) else: borrower_link = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/create_new_request_step1', {'borrower_id': borrower_id, 'ln': ln}, (name)) out += """ """ % (borrower_link, borrower_id) out += """
%s
%s




""" % (_("Back")) return out def tmpl_yourloans(self, loans, requests, borrower_id, infos, ln=CFG_SITE_LANG): """ When an user is logged in, it is possible to check his loans. In the section 'yourloans', it is also possible to renew a single loan or all loans. @param result: show all loans of an user who is logged in @param uid: user ID @param infos: display information about holdings @param ln: language """ _ = gettext_set_language(ln) renew_all_link = create_html_link(CFG_SITE_SECURE_URL + '/yourloans/display', {'borrower_id': borrower_id}, (_("Renew all loans"))) loanshistoricaloverview_link = create_html_link(CFG_SITE_SECURE_URL + '/yourloans/loanshistoricaloverview', {'ln': ln}, (_("Loans - historical overview"))) out = self.tmpl_infobox(infos, ln) if len(loans) == 0: out += """


%s


""" % (_("You don't have any book on loan.")) else: out += """
""" % (_("Item"), _("Loaned on"), _("Due date"), _("Action(s)")) for(recid, barcode, loaned_on, due_date, loan_type) in loans: record_link = "" % recid + \ (book_title_from_MARC(recid)) + "" if loan_type == 'ill': renew_link = '-' else: renew_link = create_html_link(CFG_SITE_SECURE_URL + '/yourloans/display', {'barcode': barcode}, (_("Renew"))) out += """ """ % (record_link, loaned_on, due_date, renew_link) out += """
%s %s %s %s
%s %s %s %s

%s



""" % (renew_all_link) if len(requests) == 0: out += """

%s



%s




%s


""" % (_("Your Requests"), _("You don't have any request (waiting or pending)."), loanshistoricaloverview_link, CFG_SITE_URL, _("Back to home")) else: out +="""

%s


""" % (_("Your Requests"), _("Item"), _("Request date"), _("Status"), _("Action(s)")) for(request_id, recid, request_date, status) in requests: record_link = "" % recid + \ (book_title_from_MARC(recid)) + "" cancel_request_link = create_html_link(CFG_SITE_URL + '/yourloans/display', {'request_id': request_id}, (_("Cancel"))) out += """ """ % (record_link, request_date, status, cancel_request_link) out +="""
%s %s %s %s
%s %s %s %s





%s



""" % (loanshistoricaloverview_link, CFG_SITE_URL, _("Back to home")) return out def tmpl_loanshistoricaloverview(self, result, ln): """ In the section 'yourloans' it is possible to see the loans historical overview of the user who is logged in. Bibcirculation display all loans where the status is 'returned'. @param result: show all loans where status = 'returned' @param ln: language """ _ = gettext_set_language(ln) out = """


""" % (_("Item"), _("Loaned"), _("Returned"), _("Renewalls")) for(recid, loaned_on, returned_on, nb_renewalls) in result: record_link = "" % recid + \ (book_title_from_MARC(recid)) + "" out += """ """ % (record_link, loaned_on, returned_on, nb_renewalls) out += """
%s %s %s %s
%s %s %s %s



""" % (_("Back")) return out def tmpl_new_request(self, uid, recid, barcode, ln=CFG_SITE_LANG): """ This template is used when an user want to request a book. Here it is possible to define the 'period of interest' @param uid: user ID @param recid: recID - CDS Invenio record identifier @param barcode: book's barcode @param ln: language """ _ = gettext_set_language(ln) today = datetime.date.today() out = """
%s

""" % (CFG_SITE_URL, recid, _("Enter your period of interest"), _("From"), _("Year"), _("Month"), _("Day")) out += """ """ out += """ """ % (_("To"), _("Year"), _("Month"), _("Day")) out += """
%s %s %s %s
%s %s %s %s


""" out += """


""" out = out % {'url': CFG_SITE_URL, 'from_year' : today.year, 'from_month' : today.month, 'from_day': today.day, 'to_year': today.year + 1, 'to_month': today.month, 'to_day': today.day, 'submit_button': ('Confirm'), 'recid': recid, 'uid': uid, 'barcode': barcode } return out def tmpl_new_request2(self, recid, barcode, ln=CFG_SITE_LANG): """ This template is used when an user want to request a book. Here it is possible to define the 'period of interest' @param uid: user ID @param recid: recID - CDS Invenio record identifier @param barcode: book's barcode @param ln: language """ _ = gettext_set_language(ln) today = datetime.date.today() gap = datetime.timedelta(days=180) more_6_months = (today + gap).strftime('%Y-%m-%d') out = """

%s

%s
%s




""" % (CFG_SITE_URL, CFG_SITE_URL, CFG_SITE_URL, CFG_SITE_URL, recid, _("Enter your period of interest"), _("From"),CFG_SITE_URL, today, _("To"), CFG_SITE_URL, more_6_months, barcode, _("Back"), _("Confirm")) return out def tmpl_new_request_send(self, message, ln=CFG_SITE_LANG): """ This template is used in the user interface. @param ln: language of the page """ _ = gettext_set_language(ln) out = """

%s
%s%s%s




""" % (message, _("You can see your loans "), CFG_SITE_URL + '/yourloans/display', _("here"), _("."), CFG_SITE_URL, _("Back to home")) return out def tmpl_next_loan_request_done(self, ln=CFG_SITE_LANG): """ This template is used in the admin interface, when a request is 'waiting' in the queue. @param ln: language of the page """ _ = gettext_set_language(ln) out = _MENU_ out += """


%s




""" % (_("A new loan has been registered."), CFG_SITE_URL, _("Back to home")) return out def tmpl_get_pending_requests(self, result, ln=CFG_SITE_LANG): """ @param ln: language of the page """ _ = gettext_set_language(ln) out = _MENU_ out += """
""" if len(result) == 0: out += """
%s



""" % (_("No more requests are pending."), _("Back")) else: out += """

"""% (CFG_SITE_URL, _("Name"), _("Item"), _('Library'), _("Location"), _("From"), _("To"), _("Request date"), _("Actions")) for (request_id, recid, name, borrower_id, library, location, date_from, date_to, request_date) in result: title_link = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/get_item_details', {'recid': recid, 'ln': ln}, (book_title_from_MARC(recid))) borrower_link = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/get_borrower_details', {'borrower_id': borrower_id, 'ln': ln}, (name)) out += """ """ % (CFG_SITE_URL, request_id, borrower_link, title_link, library, location, date_from, date_to, request_date, _("Delete"), CFG_SITE_URL, request_id, recid, borrower_id, _("Associate barcode")) out+= """
%s %s %s %s %s %s %s %s
%s %s %s %s %s %s %s

""" out += """



""" % (_("Back")) return out def tmpl_get_waiting_requests(self, result, ln=CFG_SITE_LANG): """ Template for the admin interface. Show pending requests(all, on loan, available) @param result: items with status = 'pending' @param ln: language """ _ = gettext_set_language(ln) out = _MENU_ out += """
""" if len(result) == 0: out += """
%s



""" % (_("No more requests are pending."), _("Back")) else: out += """

"""% (CFG_SITE_URL, _("Name"), _("Item"), _('Library'), _("Location"), _("From"), _("To"), _("Request date"), _("Options")) for (request_id, recid, name, borrower_id, library, location, date_from, date_to, request_date) in result: title_link = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/get_item_details', {'recid': recid, 'ln': ln}, (book_title_from_MARC(recid))) borrower_link = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/get_borrower_details', {'borrower_id': borrower_id, 'ln': ln}, (name)) out += """ """ % (CFG_SITE_URL, request_id, borrower_link, title_link, library, location, date_from, date_to, request_date, _("Cancel"), CFG_SITE_URL, request_id, recid, borrower_id, _("Associate barcode")) out+= """
%s %s %s %s %s %s %s %s
%s %s %s %s %s %s %s

""" out += """



""" % (_("Back")) return out def tmpl_get_next_waiting_loan_request(self, result, recid, barcode, ln=CFG_SITE_LANG): """ Template for the admin interface. Show the next request in the queue. @param result: next request with status = 'waiting' @param barcode: book's barcode @param ln: language """ _ = gettext_set_language(ln) out = """ """ out += _MENU_ if len(result) == 0: out += """




%s




""" % (_("No hold requests waiting."), CFG_SITE_URL) else: out += """


"""% (CFG_SITE_URL, _("Name"), _("Item"), _("Request status"), _("From"), _("To"), _("Request date"), _("Request options"), barcode, recid) for (id_lr, name, recid, status, date_from, date_to, request_date) in result: out += """ """ % ( name, book_title_from_MARC(recid), status, date_from, date_to, request_date, CFG_SITE_URL, id_lr, recid, barcode, _("Cancel"), CFG_SITE_URL, id_lr, barcode, _('Select hold request')) out += """
%s %s %s %s %s %s %s
%s %s %s %s %s %s






""" % (_("Back")) return out def tmpl_loan_return(self, infos, ln=CFG_SITE_LANG): """ Template for the admin interface. Used when a book return. @param ln: language """ out = self.tmpl_infobox(infos, ln) _ = gettext_set_language(ln) out += _MENU_ out += """



%s
""" % (CFG_SITE_URL, _("Barcode")) out += """



""" % (_("Reset"), _("OK")) return out def tmpl_loan_return_confirm(self, borrower_name, borrower_id, recid, barcode, return_date, result, ln=CFG_SITE_LANG): """ @param borrower_name: person who returned the book @param id_bibrec: book's recid @param barcode: book's barcode @param ln: language """ _ = gettext_set_language(ln) out = """ """ out += _MENU_ borrower_link = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/get_borrower_details', {'borrower_id': borrower_id, 'ln': ln}, (borrower_name)) title_link = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/get_item_details', {'recid': recid, 'ln': ln}, (book_title_from_MARC(recid))) out += """

%s

""" % (CFG_SITE_URL, _("The item %s, with barcode %s, has been returned with success." % (book_title_from_MARC(recid), barcode))) (_book_title, book_year, book_author, book_isbn, book_editor) = book_information_from_MARC(int(recid)) if book_isbn: book_cover = get_book_cover(book_isbn) else: book_cover = "%s/img/book_cover_placeholder.gif" % (CFG_SITE_URL) out += """
%s
""" % (_("Loan informations"), _("Borrower"), borrower_link, _("Item"), title_link, _("Author"), book_author, _("Year"), book_year, _("Publisher"), book_editor, _("ISBN"), book_isbn, _("Return date"), return_date, str(book_cover), recid, barcode) if result: out += """
%s %s
%s %s
%s %s
%s %s
%s %s
%s %s
%s %s
Book Cover
%s

%s
"""% (_("There %s request(s) on the book who has been returned." % len(result)), _("Waiting requests"), _("Name"), _("Item"), _("Request status"), _("From"), _("To"), _("Request date"), _("Request options")) for (request_id, name, recid, status, date_from, date_to, request_date) in result: out += """ """ % (CFG_SITE_URL, request_id, recid, barcode) out += """ """ % ( name, book_title_from_MARC(recid), status, date_from, date_to, request_date, _("Delete"), CFG_SITE_URL, request_id, barcode, _('Select request')) out += """
%s %s %s %s %s %s %s
%s %s %s %s %s %s
""" else: out += """
%s
""" % (_("There are no requests waiting on the item %s." % book_title_from_MARC(recid))) out += """


""" return out def tmpl_index(self, ln=CFG_SITE_LANG): """ Main page of the Admin interface. @param pending_request: display the number of pending requests @param ln: language """ _ = gettext_set_language(ln) out = """ """ out += _MENU_ out += """

%s

""" % (_("Welcome to CDS Invenio BibCirculation Admin")) out += """









""" return out def tmpl_borrower_search(self, infos, redirect='no', ln=CFG_SITE_LANG): """ Template for the admin interface. Search borrower. @param ln: language """ _ = gettext_set_language(ln) if CFG_CERN_SITE == 1: id_string = 'ccid' else: id_string = 'id' out = self.tmpl_infobox(infos, ln) out += _MENU_ out += """



%s %s name email






""" % (CFG_SITE_URL, _("Search borrower by"), id_string, redirect, _("Back"), _("Search")) return out def tmpl_item_search(self, infos, ln=CFG_SITE_LANG): """ @param ln: language of the page """ _ = gettext_set_language(ln) out = self.tmpl_infobox(infos, ln) out += _MENU_ out += """



Search item by any field barcode author title






""" % (CFG_SITE_URL, _("Back"), _("Search")) return out def tmpl_item_search_result(self, result, ln=CFG_SITE_LANG): """ @param ln: language of the page """ _ = gettext_set_language(ln) out = """ """ out += _MENU_ if result == None: out += """

%s

""" % (_("0 item(s) found.")) else: out += """

%s item(s) found

""" % (len(result), _("Title"), _("Author"), _("Publisher"), _("No. Copies")) ### FIXME: If one result -> go ahead ### for recid in result: (book_author, book_editor, book_copies) = get_item_info_for_search_result(recid) title_link = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/get_item_details', {'recid': recid, 'ln': ln}, (book_title_from_MARC(recid))) out += """ """ % (title_link, book_author, book_editor, book_copies) out += """
%s %s %s %s
%s %s %s %s




""" % (_("Back")) return out def tmpl_loan_on_desk_step1(self, result, key, string, infos, ln=CFG_SITE_LANG): """ @param ln: language of the page """ _ = gettext_set_language(ln) out = self.tmpl_infobox(infos, ln) out += _MENU_ out += """



""" % (CFG_SITE_URL) if CFG_CERN_SITE == 1: out += """
Search user by """ if key == 'email': out += """ ccid name email """ elif key == 'name': out += """ ccid name email """ else: out += """ ccid name email """ else: out += """
Search borrower by """ if key == 'email': out += """ id name email """ elif key == 'id': out += """ id name email """ else: out += """ id name email """ out += """


""" % (string or '') if result: out += """
""" % (_("Select user")) out += """


""" return out def tmpl_loan_on_desk_step2(self, user_info, infos, ln=CFG_SITE_LANG): """ @param ln: language of the page """ (id, ccid, name, email, phone, address, mailbox) = user_info _ = gettext_set_language(ln) display_id=id id_string= _("ID") if CFG_CERN_SITE == 1: display_id=ccid id_string= _("CCID") out = self.tmpl_infobox(infos, ln) out += _MENU_ out += """


""" % (CFG_SITE_URL, _("User information")) out += """
%s
""" % (id_string, display_id) out += """
%s %s
%s %s
%s %s
%s %s
%s %s
%s %s

%s



""" %( _("Name"), name, _("Email"), email, _("Phone"), phone, _("Address"), address, _("Mailbox"), mailbox, _("Barcode(s)"), _("Back"), _("Continue"),user_info) return out def tmpl_loan_on_desk_step3(self, user_info, list_of_books, infos, ln=CFG_SITE_LANG): """ @param ln: language of the page """ (id, ccid, name, email, phone, address, mailbox) = user_info #user_info = [str(ccid), str(name), str(email), str(phone), str(address), str(mailbox)] _ = gettext_set_language(ln) display_id=id id_string= _("ID") if CFG_CERN_SITE == 1: display_id=ccid id_string= _("CCID") out = self.tmpl_infobox(infos, ln) out += _MENU_ out += """


%s
%s %s
%s %s
%s %s
%s %s
%s %s
%s %s

%s
""" % (CFG_SITE_URL, list_of_books, _("User information"), id_string, display_id, _("Name"), name, _("Email"), email, _("Phone"), phone, _("Address"), address, _("Mailbox"), mailbox, _("List of borrowed books"), CFG_SITE_URL,CFG_SITE_URL, _("Item"), _("Barcode"), _("Library"), _("Location"), _("Due date"), _("Write note(s)")) iterator = 1 for (recid, barcode, library_id, location) in list_of_books: due_date = renew_loan_for_X_days(barcode) library_name = db.get_library_name(library_id) out +=""" """ % (book_title_from_MARC(recid), barcode, library_name, location, "#date_picker" + str(iterator), CFG_SITE_URL ,"date_picker" + str(iterator),due_date) iterator += 1 out += """
%s %s %s %s %s %s
%s %s %s %s



""" % ( _("Back"), _("Continue"), str(user_info)) return out def tmpl_loan_on_desk_step4(self, ln=CFG_SITE_LANG): """ @param ln: language of the page """ _ = gettext_set_language(ln) out = """ """ out += _MENU_ out +="""




A new loan has been registered.




""" % (CFG_SITE_URL) return out def tmpl_send_notification(self, ln=CFG_SITE_LANG): """ @param ln: language of the page """ _ = gettext_set_language(ln) out = """ """ out += _MENU_ out += """


%s




""" % (_("Notification has been sent!"), CFG_SITE_URL) return out def tmpl_register_new_loan(self, borrower_info, recid, ln=CFG_SITE_LANG): """ @param ln: language of the page """ (id, ccid, name, email, phone, address, mailbox) = borrower_info (book_title, book_year, book_author, book_isbn, book_editor) = book_information_from_MARC(int(recid)) _ = gettext_set_language(ln) display_id=id id_string= _("ID") if CFG_CERN_SITE == 1: display_id=ccid id_string= _("CCID") out = """ """ out += _MENU_ out += """
%s

%s %s
%s %s
%s %s
%s %s
%s %s

%s %s
%s %s
%s %s
%s %s
%s %s
%s %s



""" % (_("A new loan has been registered."), _("Name"), name, id_string, display_id, _("Email"), email, _("Phone"), phone, _("Address"), address, _("Mailbox"), mailbox, _("Name"), book_title, _("Author(s)"), book_author, _("Year"), book_year, _("Publisher"), book_editor, _("ISBN"), book_isbn, CFG_SITE_URL, _("Print loan information")) return out def tmpl_loan_on_desk_confirm(self, barcode, borrower, infos, ln=CFG_SITE_LANG): """ @param ln: language of the page0 """ _ = gettext_set_language(ln) out = self.tmpl_infobox(infos, ln) out += _MENU_ borrower_email = borrower.split(' [')[0] borrower_id = borrower.split(' [')[1] borrower_id = int(borrower_id[:-1]) out += """

""" % (CFG_SITE_URL, borrower_id, _("Borrower"), borrower_email) for (bar) in barcode: recid = db.get_id_bibrec(bar) out += """ """ % (_("Item"), book_title_from_MARC(recid), bar) out += """
%s %s
%s %s


""" % (_("Back"), _("Confirm")) return out def tmpl_all_requests(self, result, ln=CFG_SITE_LANG): """ @param ln: language of the page """ _ = gettext_set_language(ln) out = """ """ out += _MENU_ out += """

"""% (CFG_SITE_URL, _("Borrower"), _("Item"), _("Status"), _("From"), _("To"), _("Request date"), _("Option(s)")) for (id_lr, borid, name, recid, status, date_from, date_to, request_date) in result: borrower_link = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/get_borrower_details', {'borrower_id': borid, 'ln': ln}, (name)) title_link = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/get_item_details', {'recid': recid, 'ln': ln}, (book_title_from_MARC(recid))) out += """ """ % (borrower_link, title_link, status, date_from, date_to, request_date, CFG_SITE_URL, id_lr, _("Cancel hold request")) out += """
%s %s %s %s %s %s %s
%s %s %s %s %s %s



""" % (_("Back")) return out def tmpl_get_item_requests_details(self, recid, result, ln=CFG_SITE_LANG): """ @param ln: language of the page """ _ = gettext_set_language(ln) out = """ """ out += _MENU_ if len(result) == 0: out += """

%s

""" % (_("There are no requests.")) else: out += """

"""% (CFG_SITE_URL, _("Borrower"), _("Status"), _("Library"), _("Location"), _("From"), _("To"), _("Request date"), _("Option(s)")) for (borrower_id, name, id_bibrec, status, library, location, date_from, date_to, request_id, request_date) in result: borrower_link = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/get_borrower_details', {'borrower_id': borrower_id, 'ln': ln}, (name)) out += """ """ % (borrower_link, status, library, location, date_from, date_to, request_date, CFG_SITE_URL, id_bibrec, request_id, _("Cancel hold request")) out += """
%s %s %s %s %s %s %s %s
%s %s %s %s %s %s %s




""" % (CFG_SITE_URL, recid, _("Back")) return out def tmpl_get_item_details(self, recid, copies, requests, loans, req_hist_overview, loans_hist_overview, infos, ln=CFG_SITE_LANG): """ @param ln: language of the page """ _ = gettext_set_language(ln) out = self.tmpl_infobox(infos, ln) out += _MENU_ (book_title, book_year, book_author, book_isbn, book_editor) = book_information_from_MARC(int(recid)) if book_isbn: try: book_cover = get_book_cover(book_isbn) except KeyError: book_cover = "%s/img/book_cover_placeholder.gif" % (CFG_SITE_URL) else: book_cover = "%s/img/book_cover_placeholder.gif" % (CFG_SITE_URL) link_to_detailed_record = "%s" % (CFG_SITE_URL, recid, book_title) out += """

%s
%s %s
%s %s
%s %s
%s %s
%s %s
Book Cover

%s
""" % (_("Item details"), _("Name"), link_to_detailed_record, _("Author(s)"), book_author, _("Year"), book_year, _("Publisher"), book_editor, _("ISBN"), book_isbn, CFG_SITE_URL, recid, _("Edit this record"), str(book_cover), _("Additional details")) out += """ """ % (_("Barcode"), _("Status"), _("Due date"), _("Library"), _("Location"), _("Loan period"), _("No of loans"), _("Collection"), _("Description"), _("Actions")) for (barcode, loan_period, library_name, library_id, location, nb_requests, status, collection, description, due_date) in copies: library_link = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/get_library_details', {'library_id': library_id, 'ln': ln}, (library_name)) out += """ """% (barcode, status, due_date or '-', library_link, location, loan_period, nb_requests, collection or '-', description or '-') if status == 'on loan': out += """ """ % (barcode, barcode) elif status == 'missing': out += """ """ % (barcode, barcode) elif status == 'Not for loan': out += """ """ % (barcode, barcode, barcode, barcode) else: out += """ """ % (barcode, barcode, barcode, barcode) out += """
%s %s %s %s %s %s %s %s %s %s
%s %s %s %s %s %s %s %s %s

%s %s
%s %s
%s %s

%s
%s %s
%s %s

""" % (CFG_SITE_URL, recid, _("Add new copy"), CFG_SITE_URL, recid, _("Order new copy"), CFG_SITE_URL, recid, _("ILL request"), _("Hold requests and loans overview on"), time.ctime(), _("Hold requests"), len(requests), _("More details"), CFG_SITE_URL, recid, _("Loans"), len(loans), _("More details"), CFG_SITE_URL, recid, _("Historical overview"), _("Hold requests"), len(req_hist_overview), _("More details"), CFG_SITE_URL, recid, _("Loans"), len(loans_hist_overview), _("More details"), CFG_SITE_URL, recid) out += """



""" % (_("Back")) return out def tmpl_bor_requests_historical_overview(self, req_hist_overview, ln=CFG_SITE_LANG): """ Return the historical requests overview of a borrower. req_hist_overview: list of old requests. """ _ = gettext_set_language(ln) out = """ """ out += _MENU_ if len(req_hist_overview) == 0: out += """

%s

""" % (_("There are no requests.")) else: out += """


""" % (_("Item"), _("Barcode"), _("Library"), _("Location"), _("From"), _("To"), _("Request date")) for (recid, barcode, library_name, location, req_from, req_to, req_date) in req_hist_overview: title_link = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/get_item_details', {'recid': recid, 'ln': ln}, (book_title_from_MARC(recid))) out += """ """ % (title_link, barcode, library_name, location, req_from, req_to, req_date) out += """
%s %s %s %s %s %s %s
%s %s %s %s %s %s %s

""" out += """



""" % (_("Back")) return out def tmpl_bor_loans_historical_overview(self, loans_hist_overview, ln=CFG_SITE_LANG): """ Return the historical loans overview of a borrower. loans_hist_overview: list of old loans. """ _ = gettext_set_language(ln) out = """ """ out += _MENU_ if len(loans_hist_overview) == 0: out += """

%s

""" % (_("There are no loans.")) else: out += """


""" % (_("Item"), _("Barcode"), _("Library"), _("Location"), _("Loaned on"), _("Due date"), _("Returned on"), _("Renewals"), _("Overdue letters")) recid = '-' barcode = '-' library_name = '-' location = '-' loaned_on = '-' due_date = '-' returned_on = '-' nb_renew = '-' nb_overdueletters = '-' for (recid, barcode, library_name, location, loaned_on, due_date, returned_on, nb_renew, nb_overdueletters) in loans_hist_overview: title_link = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/get_item_details', {'recid': recid, 'ln': ln}, (book_title_from_MARC(recid))) out += """ """ % (title_link, barcode, library_name, location, loaned_on, due_date, returned_on, nb_renew, nb_overdueletters) out += """
%s %s %s %s %s %s %s %s %s
%s %s %s %s %s %s %s %s %s




""" % ("Back") return out def tmpl_get_item_req_historical_overview(self, req_hist_overview, ln=CFG_SITE_LANG): """ Return the historical requests overview of a item. req_hist_overview: list of old borrowers. """ _ = gettext_set_language(ln) out = """ """ out += _MENU_ if len(req_hist_overview) == 0: out += """

%s

""" % (_("There are no requests.")) else: out += """


""" % (_("Borrower"), _("Barcode"), _("Library"), _("Location"), _("From"), _("To"), _("Request date")) for (name, borrower_id, barcode, library_name, location, req_from, req_to, req_date) in req_hist_overview: borrower_link = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/get_borrower_details', {'borrower_id': borrower_id, 'ln': ln}, (name)) out += """ """ % (borrower_link, barcode, library_name, location, req_from, req_to, req_date) out += """
%s %s %s %s %s %s %s
%s %s %s %s %s %s %s




""" % (_("Back")) return out def tmpl_get_item_loans_historical_overview(self, loans_hist_overview, ln=CFG_SITE_LANG): """ Return the historical loans overview of a item. loans_hist_overview: list of old borrowers. """ _ = gettext_set_language(ln) out = """ """ out += _MENU_ out += """


""" % (_("Borrower"), _("Barcode"), _("Library"), _("Location"), _("Loaned on"), _("Due date"), _("Returned on"), _("Renewals"), _("Overdue letters")) for (name, borrower_id, barcode, library_name, location, loaned_on, due_date, returned_on, nb_renew, nb_overdueletters) in loans_hist_overview: borrower_link = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/get_borrower_details', {'borrower_id': borrower_id, 'ln': ln}, (name)) out += """ """ % (borrower_link, barcode, library_name, location, loaned_on, due_date, returned_on, nb_renew, nb_overdueletters) out += """
%s %s %s %s %s %s %s %s %s
%s %s %s %s %s %s %s %s %s




""" % (_("Back")) return out def tmpl_library_details(self, library_details, library_items, ln=CFG_SITE_LANG): """ @param ln: language of the page """ _ = gettext_set_language(ln) out = """ """ out += _MENU_ out += """

""" (library_id, name, address, email, phone, notes) = library_details no_notes_link = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/get_library_notes', {'library_id': library_id}, (_("No notes"))) see_notes_link = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/get_library_notes', {'library_id': library_id}, (_("Notes about this library"))) if notes == "": notes_link = no_notes_link else: notes_link = see_notes_link out += """
%s
%s %s
%s %s
%s %s
%s %s
%s %s
%s %s
""" % (_("Library details"), _("Name"), name, _("Address"), address, _("Email"), email, _("Phone"), phone, _("Notes"), notes_link, _("No of items"), len(library_items), CFG_SITE_URL, library_id, _("Update")) out += """




""" % (_("Back")) return out def tmpl_borrower_details(self, borrower, requests, loans, notes, ill, req_hist, loans_hist, ill_hist, ln=CFG_SITE_LANG): """ @param ln: language of the page """ _ = gettext_set_language(ln) out = """ """ out += _MENU_ (id, ccid, name, email, phone, address, mailbox) = borrower display_id=id id_string= _("ID") if CFG_CERN_SITE == 1: display_id=ccid id_string= _("CCID") #req_link = create_html_link(CFG_SITE_URL + # '/admin2/bibcirculation/get_borrower_requests_details', # {'id': id}, # (_("More details"))) no_notes_link = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/get_borrower_notes', {'borrower_id': id}, (_("No notes"))) see_notes_link = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/get_borrower_notes', {'borrower_id': id}, (_("Notes about this borrower"))) #loans_link = create_html_link(CFG_SITE_URL + # '/admin2/bibcirculation/get_borrower_loans_details', # {'id': id}, # (_("More details"))) # #ill_link = create_html_link(CFG_SITE_URL + # '/admin2/bibcirculation/get_borrower_ill_details', # {'id': id}, # (_("More details"))) # #req_hist_link = create_html_link(CFG_SITE_URL + # '/admin2/bibcirculation/bor_requests_historical_overview', # {'id': id}, # (_("More details"))) # #loans_hist_link = create_html_link(CFG_SITE_URL + # '/admin2/bibcirculation/bor_loans_historical_overview', # {'id': id}, # (_("More details"))) # #ill_hist_link = create_html_link(CFG_SITE_URL + # '/admin2/bibcirculation/bor_ill_historical_overview', # {'id': id}, # (_("More details"))) if notes == "" or str(notes) == '{}': check_notes = no_notes_link else: check_notes = see_notes_link out += """

%s
""" % (CFG_SITE_URL, id, _("Personal details"), id_string, display_id, _("Name"), name, _("Email"), email, _("Phone"), phone, _("Address"), address, _("Mailbox"), mailbox, _("Notes"), check_notes) nb_requests = len(requests) nb_loans = len(loans) nb_ill = len(ill) nb_req_hist = len(req_hist) nb_loans_hist = len(loans_hist) nb_ill_hist = len(ill_hist) out += """
%s %s
%s %s
%s %s
%s %s
%s %s
%s %s
%s %s


%s %s
%s %s
%s %s
%s %s

%s
%s %s
%s %s
%s %s


""" % (CFG_SITE_URL, id, _("Update"), CFG_SITE_URL, id, ccid, name, email, phone, address, mailbox, _("New loan"), CFG_SITE_URL, id, _("New request"), CFG_SITE_URL, id, _("New ILL request"), _("Notify this borrower"), _("Requests, Loans and ILL overview on"), time.ctime(), _("Requests"), nb_requests, CFG_SITE_URL, id, _("More details"), _("Loans"), nb_loans, CFG_SITE_URL, id, _("More details"), _("ILL"), nb_ill, CFG_SITE_URL, id, _("More details"), _("Historical overview"), _("Requests"), nb_req_hist, CFG_SITE_URL, id, _("More details"), _("Loans"), nb_loans_hist, CFG_SITE_URL, id, _("More details"), _("ILL"), nb_ill_hist, CFG_SITE_URL, id, _("More details"), _("Back")) return out def tmpl_borrower_request_details(self, result, borrower_id, ln=CFG_SITE_LANG): """ @param ln: language of the page """ _ = gettext_set_language(ln) out = """ """ out += _MENU_ if len(result) == 0: out += """

%s

""" % (_("There are no requests.")) else: out += """

"""% (CFG_SITE_URL, _("Item"), _("Request status"), _("Library"), _("Location"), _("From"), _("To"), _("Request date"), _("Request option(s)")) for (recid, status, library, location, date_from, date_to, request_date, request_id) in result: title_link = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/get_item_details', {'recid': recid, 'ln': ln}, (book_title_from_MARC(recid))) out += """ """ % (title_link, status, library, location, date_from, date_to, request_date, _("Cancel"), CFG_SITE_URL, request_id) out += """
%s %s %s %s %s %s %s %s
%s %s %s %s %s %s %s


""" % (CFG_SITE_URL, borrower_id, _("Back")) return out def tmpl_borrower_loans_details(self, borrower_loans, borrower_id, infos, ln=CFG_SITE_LANG): """ @param ln: language of the page """ _ = gettext_set_language(ln) out = self.tmpl_infobox(infos, ln) out += _MENU_ if len(borrower_loans) == 0: out += """

%s

""" % (_("There are no loans.")) else: out += """

"""% (CFG_SITE_URL, borrower_id, _("Item"), _("Barcode"), _("Loan date"), _("Due date"), _("Renewals"), _("Overdue letters"), _("Type"), _("Loan notes"), _("Loans status"), _("Loan options")) for (recid, barcode, loaned_on, due_date, nb_renewall, nb_overdue, date_overdue, loan_type, notes, loan_id, status) in borrower_loans: title_link = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/get_item_details', {'recid': recid, 'ln': ln}, (book_title_from_MARC(recid))) no_notes_link = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/get_loans_notes', {'loan_id': loan_id, 'ln': ln}, (_("No notes"))) see_notes_link = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/get_loans_notes', {'loan_id': loan_id, 'ln': ln}, (_("See notes"))) if notes == "": check_notes = no_notes_link else: check_notes = see_notes_link out += """ """ % (title_link, barcode, loaned_on, due_date, nb_renewall, nb_overdue, date_overdue, loan_type, check_notes, status, borrower_id, barcode, loan_id, recid, barcode, loan_id, borrower_id, borrower_id, recid, loan_id, barcode, loan_id) out += """
%s %s %s %s %s %s %s %s %s %s
%s %s %s %s %s %s - %s %s %s %s

""" % (CFG_SITE_URL, borrower_id, _("Renew all loans")) out += """

""" % (CFG_SITE_URL, borrower_id, _("Back")) return out def tmpl_all_loans(self, result, infos, ln=CFG_SITE_LANG): """ @param ln: language of the page """ _ = gettext_set_language(ln) out = self.tmpl_infobox(infos, ln) out += _MENU_ out += """
""" if len(result) == 0: out += """
%s



""" % (_("No result for your search."), _("Back")) else: out += """

"""% (CFG_SITE_URL, _("Borrower"), _("Item"), _("Barcode"), _("Loaned on"), _("Due date"), _("Renewals"), _("Overdue letters"), _("Loan Notes")) for (borrower_id, borrower_name, recid, barcode, loaned_on, due_date, nb_renewall, nb_overdue, date_overdue, notes, loan_id) in result: borrower_link = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/get_borrower_details', {'borrower_id': borrower_id, 'ln': ln}, (borrower_name)) see_notes_link = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/get_loans_notes', {'loan_id': loan_id, 'ln': ln}, (_("see notes"))) no_notes_link = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/get_loans_notes', {'loan_id': loan_id, 'ln': ln}, (_("no notes"))) if notes == "": check_notes = no_notes_link elif str(notes) == '{}': check_notes = no_notes_link else: check_notes = see_notes_link title_link = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/get_item_details', {'recid': recid, 'ln': ln}, (book_title_from_MARC(recid))) out += """ """ % (borrower_link, title_link, barcode, loaned_on, due_date, nb_renewall, nb_overdue, date_overdue, check_notes, CFG_SITE_URL, borrower_id, recid, loan_id, _("Send recall")) out+= """
%s %s %s %s %s %s %s %s
%s %s %s %s %s %s %s - %s %s

""" out += """



""" % (_("Back")) return out def tmpl_all_expired_loans(self, result, infos, ln=CFG_SITE_LANG): """ @param ln: language of the page """ _ = gettext_set_language(ln) out = self.tmpl_infobox(infos, ln) out += _MENU_ out += """
""" if len(result) == 0: out += """
%s



""" % (_("No result for your search."), _("Back")) else: out += """

"""% (CFG_SITE_URL, _("Borrower"), _("Item"), _("Barcode"), _("Loaned on"), _("Due date"), _("Renewals"), _("Overdue letters"), _("Loan Notes")) for (borrower_id, borrower_name, recid, barcode, loaned_on, due_date, nb_renewall, nb_overdue, date_overdue, notes, loan_id) in result: borrower_link = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/get_borrower_details', {'borrower_id': borrower_id, 'ln': ln}, (borrower_name)) see_notes_link = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/get_loans_notes', {'loan_id': loan_id, 'ln': ln}, (_("see notes"))) no_notes_link = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/get_loans_notes', {'loan_id': loan_id, 'ln': ln}, (_("no notes"))) if notes == "": check_notes = no_notes_link elif str(notes) == '{}': check_notes = no_notes_link else: check_notes = see_notes_link title_link = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/get_item_details', {'recid': recid, 'ln': ln}, (book_title_from_MARC(recid))) out += """ """ % (borrower_link, title_link, barcode, loaned_on, due_date, nb_renewall, nb_overdue, date_overdue, check_notes, CFG_SITE_URL, borrower_id, recid, loan_id, _("Send recall")) out+= """
%s %s %s %s %s %s %s %s
%s %s %s %s %s %s %s - %s %s

""" out += """



""" % (_("Back")) return out def tmpl_borrower_notification(self, email, subject, template, borrower_id, ln=CFG_SITE_LANG): """ @param result: template used for the notification @param ln: language of the page """ if subject is None: subject = "" _ = gettext_set_language(ln) out = """ """ out += _MENU_ out += """

"""% (CFG_SITE_URL, borrower_id, _("From"), _("CERN Library"), _("To")) out += """ """ % (email) out += """
%s %s
%s
%s

""" % (_("Subject"), subject, _("Message"), _("Choose a template"), template) out += """
%s %s


""" % (_("Templates"), _("Overdue letter"), _("Reminder"), _("Notification"), _("Send recall"), _("Load")) out += """



""" % (_("Back"), _("Reset"), _("Send")) return out def tmpl_all_loans_test(self, result, ln=CFG_SITE_LANG): """ @param ln: language of the page """ _ = gettext_set_language(ln) out = """ """ out += _MENU_ out += """
"""% (_("Borrower"), _("Item"), _("Barcode"), _("Loaned on"), _("Due date"), _("Renewals"), _("Overdue letters"), _("Loan Notes")) for (borrower_id, borrower_name, recid, barcode, loaned_on, due_date, nb_renewall, nb_overdue, date_overdue, notes, loan_id) in result: borrower_link = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/get_borrower_details', {'borrower_id': borrower_id, 'ln': ln}, (borrower_name)) see_notes_link = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/get_loans_notes', {'loan_id': loan_id, 'ln': ln}, (_("see notes"))) no_notes_link = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/get_loans_notes', {'loan_id': loan_id, 'ln': ln}, (_("no notes"))) if notes == "": check_notes = no_notes_link else: check_notes = see_notes_link title_link = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/get_item_details', {'recid': recid, 'ln': ln}, (book_title_from_MARC(recid))) out += """ """ % (borrower_link, title_link, barcode, loaned_on, due_date, nb_renewall, nb_overdue, date_overdue, check_notes) out += """
%s %s %s %s %s %s %s %s
%s %s %s %s %s %s %s - %s %s
""" return out def tmpl_get_item_loans_details(self, result, recid, infos, ln=CFG_SITE_LANG): """ @param ln: language of the page """ _ = gettext_set_language(ln) out = self.tmpl_infobox(infos, ln) out += _MENU_ if len(result) == 0: out += """

%s

""" % (_("There are no loans.")) else: out += """

""" % (CFG_SITE_URL, recid) out += """
"""% (_("Borrower"), _("Barcode"), _("Loaned on"), _("Due date"), _("Renewals"), _("Overdue letter"), _("Loan status"), _("Loan notes"), _("Loan options")) for (borrower_id, borrower_name, barcode, loaned_on, due_date, nb_renewall, nb_overdue, date_overdue, status, notes, loan_id) in result: borrower_link = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/get_borrower_details', {'borrower_id': borrower_id, 'ln': ln}, (borrower_name)) no_notes_link = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/get_loans_notes', {'loan_id': loan_id, 'ln': ln}, (_("No notes"))) see_notes_link = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/get_loans_notes', {'loan_id': loan_id, 'ln': ln}, (_("See notes"))) if notes == "": check_notes = no_notes_link else: check_notes = see_notes_link out += """ """ % (borrower_link, barcode, loaned_on, due_date, nb_renewall, nb_overdue, date_overdue, status, check_notes, borrower_id, barcode, loan_id, recid, barcode, loan_id, recid, loan_id) out += """
%s %s %s %s %s %s %s %s %s
%s %s %s %s %s %s - %s %s %s




""" % (CFG_SITE_URL, recid, _("Back")) return out def tmpl_associate_barcode(self, request_id, recid, borrower, infos, ln=CFG_SITE_LANG): _ = gettext_set_language(ln) (book_title, _book_year, _book_author, book_isbn, _book_editor) = book_information_from_MARC(int(recid)) if book_isbn: book_cover = get_book_cover(book_isbn) else: book_cover = "%s/img/book_cover_placeholder.gif" % (CFG_SITE_URL) out = self.tmpl_infobox(infos, ln) out += _MENU_ (id, ccid, name, email, phone, address, mailbox) = borrower display_id = id id_string= _("ID") if CFG_CERN_SITE == 1: display_id=ccid id_string= _("CCID") out += """

%s
%s %s
%s %s
%s %s
%s %s
%s %s
%s %s
"""% (CFG_SITE_URL, id, request_id, _("Personal details"), id_string, display_id, _("Name"), name, _("Email"), email, _("Phone"), phone, _("Address"), address, _("Mailbox"), mailbox) out +="""
%s
%s
Book Cover
%s
""" % (_("Item"), book_title, str(book_cover), _("Barcode")) out += """
%s

""" % (_("Write notes")) out += """



""" % (_("Back"), _("Confirm")) return out def tmpl_borrower_notes(self, borrower_notes, borrower_id, ln=CFG_SITE_LANG): _ = gettext_set_language(ln) if not borrower_notes: borrower_notes = {} else: borrower_notes = eval(borrower_notes) out = """ """ out += _MENU_ out +="""


%s
""" % (CFG_SITE_URL, borrower_id, _("Notes about borrower")) key_array = borrower_notes.keys() key_array.sort() for key in key_array: delete_note = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/get_borrower_notes', {'delete_key': key, 'borrower_id': borrower_id, 'ln': ln}, (_("[delete]"))) out += """ """ % (key, borrower_notes[key], delete_note) out += """
%s %s %s

%s




""" % (_("Write new note"), CFG_SITE_URL, borrower_id, _("Back"), _("Confirm")) return out def tmpl_get_loans_notes(self, loans_notes, loan_id, referer, back="", ln=CFG_SITE_LANG): _ = gettext_set_language(ln) if back == "": back=referer if not loans_notes: loans_notes = {} else: loans_notes = eval(loans_notes) out = """ """ out += _MENU_ out +="""


%s
""" % (CFG_SITE_URL, loan_id, _("Notes about loan")) key_array = loans_notes.keys() key_array.sort() for key in key_array: delete_note = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/get_loans_notes', {'delete_key': key, 'loan_id': loan_id, 'ln': ln, 'back': cgi.escape(back, True)}, (_("[delete]"))) out += """ """ % (key, loans_notes[key], delete_note) out += """
%s %s %s

%s




""" % (_("Write new note"), _("Back"), cgi.escape(back,True), _("Confirm"), cgi.escape(back, True)) return out def tmpl_new_item(self, book_info=None, errors=None, ln=CFG_SITE_LANG): """ No more in use. """ _ = gettext_set_language(ln) out = """ """ out += _MENU_ if book_info: out += """

%s
%s
Book Cover
%s
%s
%s
%s
%s
%s
%s
%s
%s
%s
%s
%s
%s
%s


""" % (_("Book Information"), _("Title"), book_info[6], book_info[8], _("Author"), book_info[0], _("EAN"), book_info[1], _("ISBN"), book_info[2], _("Publisher"), book_info[3], _("Publication date"), book_info[5], _("Publication place"), _("Edition"), book_info[7], _("Number of pages"), book_info[4], _("Sub-library"), _("CERN Central Library"), _("Location"), _("Loan period"), _("Barcode"), _("Collection"), _("Description")) elif errors: out += """



ERROR: %s. %s




""" % (CFG_SITE_URL, errors[0], errors[1]) else: out += """



'%s'




""" % (CFG_SITE_URL, _("ISBN")) return out def tmpl_add_new_borrower_step1(self, ln=CFG_SITE_LANG): _ = gettext_set_language(ln) out = """ """ out += _MENU_ out += """


%s
%s
%s
%s
%s
%s



""" % (CFG_SITE_URL, _("Name"), _("Email"), _("Phone"), _("Address"), _("Mailbox"), _("Notes"), _("Back"), _("Continue")) return out def tmpl_add_new_borrower_step2(self, tup_infos, infos, ln=CFG_SITE_LANG): _ = gettext_set_language(ln) (name, email, phone, address, mailbox, notes) = tup_infos out = self.tmpl_infobox(infos, ln) out += _MENU_ out += """


%s %s
%s %s
%s %s
%s %s
%s %s
%s %s
""" % (CFG_SITE_URL, _("Name"), name, _("Email"), email, _("Phone"), phone, _("Address"), address, _("Mailbox"), mailbox, _("Notes"), notes) if infos: out += """


""" % (_("Back")) else: out += """


""" % (_("Back"), _("Continue"), tup_infos) return out def tmpl_add_new_borrower_step3(self, ln=CFG_SITE_LANG): _ = gettext_set_language(ln) out = """ """ out += _MENU_ out += """


%s



""" % (_("A new borrower has been registered."), _("Back to home"), CFG_SITE_URL) return out def tmpl_update_borrower_info_step1(self, ln=CFG_SITE_LANG): """ Template for the admin interface. Search borrower. @param ln: language """ _ = gettext_set_language(ln) out = """ """ out += _MENU_ out += """



%s ccid name email






""" % (CFG_SITE_URL, _("Search borrower by")) return out def tmpl_update_borrower_info_step2(self, result, ln=CFG_SITE_LANG): """ @param result: search result @param ln: language """ _ = gettext_set_language(ln) out = """ """ out += _MENU_ out += """

%s borrowers found

""" % (len(result)) for (borrower_id, name) in result: borrower_link = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/update_borrower_info_step3', {'borrower_id': borrower_id, 'ln': ln}, (name)) out += """ """ % (borrower_link, borrower_id) out += """
%s

""" out += """



""" % (_("Back")) return out def tmpl_update_borrower_info_step3(self, result, ln=CFG_SITE_LANG): _ = gettext_set_language(ln) (borrower_id, ccid, name, email, phone, address, mailbox) = result display_id = borrower_id id_string= _("ID") if CFG_CERN_SITE == 1: display_id=ccid id_string= _("CCID") out = """ """ out += _MENU_ out += """


%s
%s %s
%s
%s
%s
%s
%s



""" % (CFG_SITE_URL, _("Borrower information"), id_string, display_id, _("Name"), name, _("Email"), email, _("Phone"), phone, _("Address"), address, _("Mailbox"), mailbox, _("Back"), _("Continue")) return out def tmpl_update_borrower_info_step4(self, tup_infos, ln=CFG_SITE_LANG): _ = gettext_set_language(ln) (name, email, phone, address, mailbox) = tup_infos out = """ """ out += _MENU_ out += """


%s
%s %s
%s %s
%s %s
%s %s
%s %s



""" % (CFG_SITE_URL, _("Borrower information"), _("Name"), name, _("Email"), email, _("Phone"), phone, _("Address"), address, _("Mailbox"), mailbox, _("Back"), _("Confirm"), tup_infos) return out def tmpl_update_borrower_info_step5(self, ln=CFG_SITE_LANG): _ = gettext_set_language(ln) out = """ """ out += _MENU_ out += """


%s



""" % (_("The information has been updated."), _("Back to home"), CFG_SITE_URL) return out def tmpl_add_new_library_step1(self, ln=CFG_SITE_LANG): _ = gettext_set_language(ln) out = """ """ out += _MENU_ out += """


%s
%s
%s
%s
%s
%s
%s



""" % (CFG_SITE_URL, _("New library information"), _("Name"), _("Email"), _("Phone"), _("Address"), _("Type"), _("Notes"), _("Back"), _("Continue")) return out def tmpl_add_new_library_step2(self, tup_infos, ln=CFG_SITE_LANG): _ = gettext_set_language(ln) (name, email, phone, address, lib_type, notes) = tup_infos out = """ """ out += _MENU_ out += """


%s
%s %s
%s %s
%s %s
%s %s
%s %s
%s %s



""" % (CFG_SITE_URL, _("New library information"), _("Name"), name, _("Email"), email, _("Phone"), phone, _("Address"), address, _("Type"), lib_type, _("Notes"), notes, _("Back"), _("Confirm"), tup_infos) return out def tmpl_add_new_library_step3(self, ln=CFG_SITE_LANG): _ = gettext_set_language(ln) out = """ """ out += _MENU_ out += """


%s



""" % (_("A new library has been registered."), _("Back to home"), CFG_SITE_URL) return out def tmpl_update_library_info_step1(self, infos, ln=CFG_SITE_LANG): """ Template for the admin interface. Search borrower. @param ln: language """ _ = gettext_set_language(ln) out = self.tmpl_infobox(infos, ln) out += _MENU_ out += """



%s name email






""" % (CFG_SITE_URL, _("Search library by"), _("Back")) return out def tmpl_update_library_info_step2(self, result, ln=CFG_SITE_LANG): """ @param result: search result @param ln: language """ _ = gettext_set_language(ln) out = """ """ out += _MENU_ out += """

%s library(ies) found

""" % (len(result), _("Library(ies)")) for (library_id, name) in result: library_link = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/update_library_info_step3', {'library_id': library_id, 'ln': ln}, (name)) out += """ """ % (library_link, library_id) out += """
%s
%s

""" out += """



""" % (_("Back")) return out def tmpl_update_library_info_step3(self, library_info, ln=CFG_SITE_LANG): _ = gettext_set_language(ln) (library_id, name, address, email, phone, _notes) = library_info out = """ """ out += _MENU_ out += """


%s
%s
%s
%s
%s



""" % (CFG_SITE_URL, library_id, _("Library information"), _("Name"), name, _("Email"), email, _("Phone"), phone, _("Address"), address, _("Back"), _("Continue")) return out def tmpl_update_library_info_step4(self, tup_infos, ln=CFG_SITE_LANG): (_library_id, name, email, phone, address) = tup_infos _ = gettext_set_language(ln) out = """ """ out += _MENU_ out += """


%s
%s %s
%s %s
%s %s
%s %s



""" % (CFG_SITE_URL, _("Library information"), _("Name"), name, _("Email"), email, _("Phone"), phone, _("Address"), address, _("Back"), _("Continue"), tup_infos) return out def tmpl_update_library_info_step5(self, ln=CFG_SITE_LANG): """ @param ln: language of the page """ _ = gettext_set_language(ln) out = """ """ out += _MENU_ out += """


%s



""" % (_("The information has been updated."), _("Back to home"), CFG_SITE_URL) return out def tmpl_new_book_step1(self, ln=CFG_SITE_LANG): _ = gettext_set_language(ln) out = _MENU_ out += """



%s
%s
%s
%s
%s
%s
%s
%s

""" % (CFG_SITE_URL, _("Item details"), _("Book title"), _("Author(s)"), _("Place"), _("Publisher"), _("Year"), _("Edition"), _("ISBN")) #conditions_link = """conditions""" out += """


""" % (_("Back"), _("Continue")) return out def tmpl_new_book_step2(self, ln=CFG_SITE_LANG): ### FIXME ### return "Coming soon..." def tmpl_add_new_copy_step1(self): """ @param ln: language of the page """ out = _MENU_ out += """



Search item by any field year author title






""" % (CFG_SITE_URL) return out def tmpl_add_new_copy_step2(self, result, ln=CFG_SITE_LANG): """ @param ln: language of the page """ _ = gettext_set_language(ln) out = """ """ out += _MENU_ out += """


%s items found
""" % (len(result)) for recid in result: title_link = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/add_new_copy_step3', {'recid': recid, 'ln': ln}, (book_title_from_MARC(recid))) out += """ """ % (title_link) out += """
%s

""" out += """



""" return out def tmpl_add_new_copy_step3(self, recid, result, libraries, infos, ln=CFG_SITE_LANG): """ @param ln: language of the page """ _ = gettext_set_language(ln) out = self.tmpl_infobox(infos, ln) out += _MENU_ (book_title, book_year, book_author, book_isbn, book_editor) = book_information_from_MARC(int(recid)) if book_isbn: book_cover = get_book_cover(book_isbn) else: book_cover = "%s/img/book_cover_placeholder.gif" % (CFG_SITE_URL) out += """

%s
%s %s
%s %s
%s %s
%s %s
%s %s
Book Cover

%s
""" % (CFG_SITE_URL, _("Item details"), _("Name"), book_title, _("Author(s)"), book_author, _("Year"), book_year, _("Publisher"), book_editor, _("ISBN"), book_isbn, str(book_cover), _("Copies of %s" % book_title)) out += """""" % (_("Barcode"), _("Status"), _("Due date"), _("Library"), _("Location"), _("Loan period"), _("No of loans"), _("Collection"), _("Description")) for (barcode, loan_period, lib_name, libid, location, nb_requests, status, collection, description, due_date) in result: library_link = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/get_library_details', {'library_id': libid, 'ln': ln}, (lib_name)) out += """ """ % (barcode, status, due_date, library_link, location, loan_period, nb_requests, collection or '-', description or '-') out += """
%s %s %s %s %s %s %s %s %s
%s %s %s %s %s %s %s %s %s

%s
%s
%s
%s
%s
%s
%s
%s



""" % (_("Location"), _("Collection"), _("Description"), _("Loan period"), _("Status"), recid) return out def tmpl_add_new_copy_step4(self, tup_infos, ln=CFG_SITE_LANG): """ @param tup_info: item's informations @type tup_info: tuple @param ln: language of the page """ _ = gettext_set_language(ln) out = """ """ out += _MENU_ out += """


%s %s
%s %s
%s %s
%s %s
%s %s
%s %s
%s %s



""" % (CFG_SITE_URL, _("Barcode"), tup_infos[0], _("Library"), tup_infos[2], _("Location"), tup_infos[3], _("Collection"), tup_infos[4], _("Description"), tup_infos[5], _("Loan period"), tup_infos[6], _("Status"), tup_infos[7], _("Back"), _("Continue"), tup_infos) return out def tmpl_add_new_copy_step5(self, recid, ln=CFG_SITE_LANG): """ @param recid: identify the record. Primary key of bibrec. @type recid: int """ _ = gettext_set_language(ln) item_link = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/get_item_details', {'recid': recid, 'ln': ln}, (_("new copy"))) out = """ """ out += _MENU_ out += """


%s



""" % (_("A %s has been added." % (item_link)), _("Back to home"), CFG_SITE_URL) return out def tmpl_update_item_info_step1(self): """ @param ln: language of the page """ out = """ """ out += _MENU_ out += """



Search item by any field year author title






""" % (CFG_SITE_URL) return out def tmpl_update_item_info_step2(self, result, ln=CFG_SITE_LANG): """ @param result: list with recids @type result: list @param ln: language of the page """ _ = gettext_set_language(ln) out = """ """ out += _MENU_ out += """


%s items found
""" % (len(result)) for recid in result: title_link = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/update_item_info_step3', {'recid': recid, 'ln': ln}, (book_title_from_MARC(recid))) out += """ """ % (title_link) out += """
%s




""" return out def tmpl_update_item_info_step3(self, recid, result, ln=CFG_SITE_LANG): """ @param recid: identify the record. Primary key of bibrec. @type recid: int @param result: book's information @type result: tuple @param ln: language of the page """ _ = gettext_set_language(ln) out = """ """ out += _MENU_ (book_title, book_year, book_author, book_isbn, book_editor) = book_information_from_MARC(int(recid)) if book_isbn: book_cover = get_book_cover(book_isbn) else: book_cover = "%s/img/book_cover_placeholder.gif" % (CFG_SITE_URL) out += """

%s
%s %s
%s %s
%s %s
%s %s
%s %s
Book Cover

""" % (CFG_SITE_URL, _("Item details"), _("Name"), book_title, _("Author(s)"), book_author, _("Year"), book_year, _("Publisher"), book_editor, _("ISBN"), book_isbn, str(book_cover)) out += """""" % (_("Barcode"), _("Status"), _("Library"), _("Location"), _("Loan period"), _("No of loans"), _("Collection"), _("Description")) for (barcode, loan_period, lib_name, libid, location, nb_requests, status, collection, description) in result: library_link = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/get_library_details', {'library_id': libid, 'ln': ln}, (lib_name)) out += """ """ % (barcode, status, library_link, location, loan_period, nb_requests, collection, description, CFG_SITE_URL, barcode, _("Update")) out += """
%s %s %s %s %s %s %s %s
%s %s %s %s %s %s %s %s



""" % (_("Back"), recid) return out def tmpl_update_item_info_step4(self, recid, result, libraries, ln=CFG_SITE_LANG): """ @param recid: identify the record. Primary key of bibrec @type recid: int @param result: book's information @type result: tuple @param libraries: list of libraries @type libraries: list @param ln: language of the page """ _ = gettext_set_language(ln) out = """ """ out += _MENU_ (book_title, book_year, book_author, book_isbn, book_editor) = book_information_from_MARC(int(recid)) if book_isbn: book_cover = get_book_cover(book_isbn) else: book_cover = "%s/img/book_cover_placeholder.gif" % (CFG_SITE_URL) out += """

%s
%s %s
%s %s
%s %s
%s %s
%s %s
Book Cover

""" % (CFG_SITE_URL, _("Item details"), _("Name"), book_title, _("Author(s)"), book_author, _("Year"), book_year, _("Publisher"), book_editor, _("ISBN"), book_isbn, str(book_cover)) out += """
%s
%s %s
%s
%s
%s
%s
%s
%s



""" % (_("Back"), _("Continue"), recid) return out def tmpl_update_item_info_step5(self, tup_infos, ln=CFG_SITE_LANG): """ @param tup_info: item's informations @type tup_info: tuple @param ln: language of the page """ _ = gettext_set_language(ln) out = """ """ out += _MENU_ out += """


%s
%s %s
%s %s
%s %s
%s %s
%s %s
%s %s
%s %s



""" % (CFG_SITE_URL, _("New copy information"), _("Barcode"), tup_infos[0], _("Library"), tup_infos[2], _("Location"), tup_infos[3], _("Collection"), tup_infos[4], _("Description"), tup_infos[5], _("Loan period"), tup_infos[6], _("Status"), tup_infos[7], _("Back"), _("Confirm"), tup_infos) return out def tmpl_update_item_info_step6(self, ln=CFG_SITE_LANG): """ @param ln: language of the page """ _ = gettext_set_language(ln) out = """ """ out += _MENU_ out += """


%s



""" % (_("This item has been updated."), _("Back to home"), CFG_SITE_URL) return out def tmpl_search_library_step1(self, infos, ln=CFG_SITE_LANG): """ Template for the admin interface. Search borrower. @param infos: informations @type infos: list @param ln: language """ _ = gettext_set_language(ln) out = self.tmpl_infobox(infos, ln) out += _MENU_ out += """



%s name email






""" % (CFG_SITE_URL, _("Search library by"), _("Back"), _("Search")) return out def tmpl_search_library_step2(self, result, ln=CFG_SITE_LANG): """ @param result: search result about libraries @type result: list @param ln: language """ _ = gettext_set_language(ln) out = """ """ out += _MENU_ if len(result) == 0: out += """

%s

""" % (_("0 library(ies) found.")) else: out += """

%s library(ies) found

""" % (len(result), _("Library(ies)")) for (library_id, name) in result: library_link = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/get_library_details', {'library_id': library_id, 'ln': ln}, (name)) out += """ """ % (library_link, library_id) out += """
%s
%s




""" % (_("Back")) return out def tmpl_library_notes(self, library_notes, library_id, ln=CFG_SITE_LANG): """ @param library_notes: notes about a library @type library_notes: dictionnary @param library_id: identify the library. Primary key of crcLIBRARY @type library_id: int @param ln: language of the page """ _ = gettext_set_language(ln) if not library_notes: library_notes = {} else: library_notes = eval(library_notes) out = """ """ out += _MENU_ out +="""


%s
""" % (CFG_SITE_URL, library_id, _("Notes about library")) key_array = library_notes.keys() key_array.sort() for key in key_array: delete_note = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/get_library_notes', {'delete_key': key, 'library_id': library_id, 'ln': ln}, (_("[delete]"))) out += """ """ % (key, library_notes[key], delete_note) out += """
%s %s %s

%s




""" % (_("Write new note"), CFG_SITE_URL, library_id, _("Back"), _("Confirm")) return out def tmpl_change_due_date_step1(self, loan_details, loan_id, borrower_id, ln=CFG_SITE_LANG): """ Return the form where the due date can be changed. @param loan_details: the information related with the loan. @type loan_details: tuple @param loan_id: identify the loan. Primary key of crcLOAN. @type loan_id: int @param borrower_id: identify the borrower. Primary key of crcBORROWER. @type borrower_id: int @param ln: language of the page """ _ = gettext_set_language(ln) out = """ """ out += _MENU_ (recid, barcode, loaned_on, due_date, loan_status, loan_period, item_status) = loan_details if item_status == 'requested': request_status = 'Yes' else: request_status = 'No' out +="""


%s
%s %s
%s %s
%s %s
%s %s
%s %s
%s %s
%s %s

""" % (CFG_SITE_URL, _("Loan information"), _("Title"), book_title_from_MARC(recid), _("Barcode"), barcode, _("Loan date"), loaned_on, _("Due date"), due_date, _("Loan status"), loan_status, _("Loan period"), loan_period, _("Requested ?"), request_status) out += """
%s

""" % (CFG_SITE_URL, CFG_SITE_URL, _("New due date: "), CFG_SITE_URL, due_date) out += """


""" % (loan_id, borrower_id, _("Back"), _("Submit new due date")) return out def tmpl_change_due_date_step2(self, new_due_date, borrower_id, ln=CFG_SITE_LANG): """ Return a page with the new due date. @param due_date: new due date @type due_date: string @param borrower_id: identify the borrower. Primary key of crcBORROWER. @type borrower_id: int @param ln: language of the page """ _ = gettext_set_language(ln) out = """ """ out += _MENU_ out += """


%s



""" % (_("The due date has been updated. New due date: %s" % (new_due_date)), CFG_SITE_URL, borrower_id, cgi.escape(_("Back to borrower´s loans"),True)) return out def tmpl_create_new_loan_step1(self, borrower, infos, ln=CFG_SITE_LANG): """ Display the borrower's information and a form where it is possible to search for an item. @param borrower: borrower's information. @type borrower: tuple @param infos: informations @type infos: list @param ln: language of the page """ _ = gettext_set_language(ln) out = self.tmpl_infobox(infos, ln) out += _MENU_ (borrower_id, ccid, name, email, phone, address, mailbox) = borrower display_id = borrower_id id_string= _("ID") if CFG_CERN_SITE == 1: display_id=ccid id_string= _("CCID") out += """

%s
%s %s
%s %s
%s %s
%s %s
%s %s
"""% (CFG_SITE_URL, borrower_id, _("Personal details"), id_string, display_id, _("Name"), name, _("Email"), email, _("Phone"), phone, _("Address"), address, _("Mailbox"), mailbox) out +="""
%s
""" % (_("Barcode")) out += """
%s

""" % (_("Write notes")) out += """



""" % (_("Back"), _("Confirm")) return out def tmpl_create_new_request_step1(self, borrower, infos, result, p, f, ln=CFG_SITE_LANG): """ Display the borrower's information and the form where it is possible to search for an item. @param borrower: borrower's information. @type borrower: tuple @param infos: informations @type infos: list @param result: result of searching for an item, using p and f. @type result: list @param p: pattern who will be used in the search process. @type p: string @param f: field who will be used in the search process. @type f: string @param ln: language of the page """ _ = gettext_set_language(ln) out = self.tmpl_infobox(infos, ln) out += _MENU_ (borrower_id, ccid, name, email, phone, address, mailbox) = borrower display_id = borrower_id id_string= _("ID") if CFG_CERN_SITE == 1: display_id=ccid id_string= _("CCID") out += """


"""% (_("Borrower details"), id_string, display_id, _("Name"), name, _("Email"), email, _("Phone"), phone, _("Address"), address, _("Mailbox"), mailbox) out += """
Search item by """%(CFG_SITE_URL, borrower_id) if f == 'barcode': out += """ any field barcode author title """ elif f == 'author': out += """ any field barcode author title """ elif f == 'title': out += """ any field barcode author title """ else: out += """ any field barcode author title """ out += """


""" % (p or '', _("Back"), _("Search")) if result: out += """
""" % (_("Select item"), borrower_id) out += """
%s
%s %s
%s %s
%s %s
%s %s
%s %s
%s %s





""" return out def tmpl_create_new_request_step2(self, user_info, holdings_information, recid, ln=CFG_SITE_LANG): """ @param borrower_id: identify the borrower. Primary key of crcBORROWER. @type borrower_id: int @param holdings_information: information about holdings @type holdings_information: list @param recid: identify the record. Primary key of bibrec. @type recid: int """ _ = gettext_set_language(ln) if not holdings_information: return _("This item has no holdings.") out = """ """ out += _MENU_ out += """



""" % (_("Barcode"), _("Library"), _("Collection"), _("Location"), _("Description"), _("Loan period"), _("Status"), _("Due date")) for (barcode, library, collection, location, description, loan_period, status, due_date) in holdings_information: out += """ """ % (barcode, library, collection, location, description, loan_period, status, due_date, CFG_SITE_URL, barcode, recid, user_info[0],user_info[1],user_info[2],user_info[3],user_info[4],user_info[5],user_info[6], _("Request")) out += """
%s %s %s %s %s %s %s %s
%s %s %s %s %s %s %s %s



""" return out def tmpl_create_new_request_step3(self, borrower_id, barcode, recid, ln=CFG_SITE_LANG): """ @param borrower_id: identify the borrower. Primary key of crcBORROWER. @type borrower_id: int @param barcode: identify the item. Primary key of crcITEM. @type barcode: string @param recid: identify the record. Primary key of bibrec. @type recid: int @param ln: language """ _ = gettext_set_language(ln) out = """ """ out += _MENU_ out += """



%s

%s
%s


""" % (CFG_SITE_URL, CFG_SITE_URL, CFG_SITE_URL, _("Enter the period of interest"), _("From: "), CFG_SITE_URL, datetime.date.today().strftime('%Y-%m-%d'), _("To: "), CFG_SITE_URL, (datetime.date.today() + datetime.timedelta(days=365)).strftime('%Y-%m-%d')) out += """


""" % (barcode, borrower_id, recid, _('Confirm')) return out def tmpl_create_new_request_step4(self, ln=CFG_SITE_LANG): """ Last step of the request procedure. @param ln: language of the page """ _ = gettext_set_language(ln) out = """ """ out += _MENU_ out += """


%s




""" % (_("A new request has been registered with success."), CFG_SITE_URL, _("Back to home")) return out def tmpl_place_new_request_step1(self, result, key, string, barcode, recid, infos, ln=CFG_SITE_LANG): """ @param result: borrower's information @type result: list @param key: field (name, email, etc...) @param key: string @param string: pattern @type string: string @param barcode: identify the item. Primary key of crcITEM. @type barcode: string @param recid: identify the record. Primary key of bibrec @type recid: int @param infos: informations @type infos: list @param ln: language of the page """ _ = gettext_set_language(ln) (book_title, book_year, book_author, book_isbn, book_editor) = book_information_from_MARC(int(recid)) if book_isbn: book_cover = get_book_cover(book_isbn) else: book_cover = "%s/img/book_cover_placeholder.gif" % (CFG_SITE_URL) out = self.tmpl_infobox(infos, ln) out += _MENU_ out += """


""" % (_("Item details"), _("Name"), book_title, _("Author(s)"), book_author, _("Year"), book_year, _("Publisher"), book_editor, _("ISBN"), book_isbn, _("Barcode"), barcode, str(book_cover)) out += """
%s
%s %s
%s %s
%s %s
%s %s
%s %s
%s %s
Book Cover
""" % (CFG_SITE_URL, barcode, recid) if CFG_CERN_SITE == 1: out += """
Search user by """ if key == 'email': out += """ ccid name email """ elif key == 'name': out += """ ccid name email """ else: out += """ ccid name email """ else: out += """
Search borrower by """ if key == 'email': out += """ id name email """ elif key == 'id': out += """ id name email """ else: out += """ id name email """ out += """


""" % (string or '') if result: out += """
""" % (_("Select user")) out += """




""" return out def tmpl_place_new_request_step2(self, barcode, recid, user_info, infos, ln=CFG_SITE_LANG): """ @param barcode: identify the item. Primary key of crcITEM. @type barcode: string @param recid: identify the record. Primary key of bibrec @type recid: int @param user_info: user's informations @type user_info: tuple @param infos: informations @type infos: list @param ln: language of the page """ (book_title, book_year, book_author, book_isbn, book_editor) = book_information_from_MARC(int(recid)) if book_isbn: book_cover = get_book_cover(book_isbn) else: book_cover = "%s/img/book_cover_placeholder.gif" % (CFG_SITE_URL) (id,ccid, name, email, phone, address, mailbox) = user_info _ = gettext_set_language(ln) out = self.tmpl_infobox(infos, ln) out += _MENU_ out += """


""" % (CFG_SITE_URL, barcode, recid, user_info, _("Item details"), _("Name"), book_title, _("Author(s)"), book_author, _("Year"), book_year, _("Publisher"), book_editor, _("ISBN"), book_isbn, _("Barcode"), barcode, str(book_cover)) out += """
%s
%s %s
%s %s
%s %s
%s %s
%s %s
%s %s
Book Cover
%s
%s %s
%s %s
%s %s
%s %s
%s %s
%s %s
""" % (_("Borrower details"), _("ID"), ccid, _("Name"), name, _("Email"), email, _("Phone"), phone, _("Address"), address, _("Mailbox"), mailbox) out += """
%s
%s
%s




""" % (CFG_SITE_URL ,CFG_SITE_URL, _("Enter the period of interest"), _("From: "), CFG_SITE_URL, datetime.date.today().strftime('%Y-%m-%d'), _("To: "), CFG_SITE_URL, (datetime.date.today() + datetime.timedelta(days=365)).strftime('%Y-%m-%d'), _("Back"), _("Continue")) return out def tmpl_place_new_request_step3(self, ln=CFG_SITE_LANG): """ Last step of the request procedure. """ _ = gettext_set_language(ln) out = """ """ out += _MENU_ out += """


%s




""" % (_("A new request has been registered with success."), CFG_SITE_URL, _("Back to home")) return out def tmpl_place_new_loan_step1(self, result, key, string, barcode, recid, infos, ln=CFG_SITE_LANG): """ @param result: borrower's information @type result: list @param key: field (name, email, etc...) @param key: string @param string: pattern @type string: string @param barcode: identify the item. Primary key of crcITEM. @type barcode: string @param recid: identify the record. Primary key of bibrec @type recid: int @param infos: informations @type infos: list @param ln: language of the page """ _ = gettext_set_language(ln) (book_title, book_year, book_author, book_isbn, book_editor) = book_information_from_MARC(int(recid)) if book_isbn: book_cover = get_book_cover(book_isbn) else: book_cover = "%s/img/book_cover_placeholder.gif" % (CFG_SITE_URL) out = self.tmpl_infobox(infos, ln) out += _MENU_ out += """

%s
""" % (_("Item details"), _("Name"), book_title, _("Author(s)"), book_author, _("Year"), book_year, _("Publisher"), book_editor, _("ISBN"), book_isbn, _("Barcode"), barcode, str(book_cover)) out += """
%s %s
%s %s
%s %s
%s %s
%s %s
%s %s
Book Cover
""" % (CFG_SITE_URL, barcode, recid) if CFG_CERN_SITE == 1: out += """
Search user by """ if key == 'email': out += """ ccid name email """ elif key == 'name': out += """ ccid name email """ else: out += """ ccid name email """ else: out += """
Search borrower by """ if key == 'email': out += """ id name email """ elif key == 'id': out += """ id name email """ else: out += """ id name email """ out += """


""" % (string or '') # if result: out += """
""" % (_("Select user")) out += """




""" return out def tmpl_place_new_loan_step2(self, barcode, recid, user_info, ln=CFG_SITE_LANG): """ @param barcode: identify the item. Primary key of crcITEM. @type barcode: string @param recid: identify the record. Primary key of bibrec. @type recid: int @param user_info: user's informations @type user_info: tuple @param ln: language of the page """ (book_title, book_year, book_author, book_isbn, book_editor) = book_information_from_MARC(int(recid)) if book_isbn: book_cover = get_book_cover(book_isbn) else: book_cover = "%s/img/book_cover_placeholder.gif" % (CFG_SITE_URL) (id, ccid, name, email, phone, address, mailbox) = user_info.split(',') _ = gettext_set_language(ln) out = """ """ out += _MENU_ out += """

%s
%s %s
%s %s
%s %s
%s %s
%s %s
%s %s
Book Cover

""" % (CFG_SITE_URL, barcode, recid, email, _("Item details"), _("Name"), book_title, _("Author(s)"), book_author, _("Year"), book_year, _("Publisher"), book_editor, _("ISBN"), book_isbn, _("Barcode"), barcode, str(book_cover)) out += """
%s
%s %s
%s %s
%s %s
%s %s
%s %s
%s %s

""" % (_("Borrower details"), _("ID"), ccid, _("Name"), name, _("Email"), email, _("Phone"), phone, _("Address"), address, _("Mailbox"), mailbox) out += """
%s
%s %s
%s


%s
This note will be associate to this new loan, not to the borrower.




""" % (CFG_SITE_URL, CFG_SITE_URL, _("Loan information"), _("Loan date"), datetime.date.today().strftime('%Y-%m-%d'), _("Due date"), CFG_SITE_URL, renew_loan_for_X_days(barcode), _("Write notes"), _("Back"), _("Continue")) return out def tmpl_order_new_copy_step1(self, recid, list_of_vendors, libraries, ln=CFG_SITE_LANG): """ @param recid: identify the record. Primary key of bibrec. @type recid: int @param list_of_vendors: list with all the vendores @type list_of_vendors: list @param libraries: all libraries @type libraries: list @param ln: language of the page """ _ = gettext_set_language(ln) out = """ """ out += _MENU_ (book_title, book_year, book_author, book_isbn, book_editor) = book_information_from_MARC(int(recid)) if book_isbn: book_cover = get_book_cover(book_isbn) else: book_cover = "%s/img/book_cover_placeholder.gif" % (CFG_SITE_URL) out += """

%s
%s %s
%s %s
%s %s
%s %s
%s %s
Book Cover

""" % (CFG_SITE_URL, _("Item details"), recid, _("Name"), book_title, _("Author(s)"), book_author, _("Year"), book_year, _("Publisher"), book_editor, _("ISBN"), book_isbn, str(book_cover)) out += """
%s
%s *
%s
%s
%s
%s
%s
%s
%s



""" % (_("Notes"), _("Back"), _("Continue")) return out def tmpl_order_new_copy_step2(self, order_info, ln=CFG_SITE_LANG): """ @param order_info: order's informations @type order_info: tuple @param ln: language of the page """ (recid, barcode, vendor_id, cost, currency, status, order_date, expected_date, library_id, notes) = order_info (book_title, book_year, book_author, book_isbn, book_editor) = book_information_from_MARC(int(recid)) vendor_name = db.get_vendor_name(vendor_id) library_name = db.get_library_name(library_id) if book_isbn: book_cover = get_book_cover(book_isbn) else: book_cover = "%s/img/book_cover_placeholder.gif" % (CFG_SITE_URL) _ = gettext_set_language(ln) out = """ """ out += _MENU_ out += """

%s
%s %s
%s %s
%s %s
%s %s
%s %s
Book Cover

""" % (CFG_SITE_URL, order_info, _("Item details"), _("Name"), book_title, _("Author(s)"), book_author, _("Year"), book_year, _("Publisher"), book_editor, _("ISBN"), book_isbn, str(book_cover)) out += """
%s
%s %s
%s %s
%s %s %s
%s %s
%s %s
%s %s
%s %s
%s %s



""" % (_("Order details"), _("Barcode"), barcode, _("Vendor"), vendor_name, _("Price"), cost, currency, _("Status"), status, _("Order date"), order_date, _("Expected date"), expected_date, _("Library"), library_name, _("Notes"), notes, _("Back"), _("Continue")) return out def tmpl_order_new_copy_step3(self, ln=CFG_SITE_LANG): """ Last step of the request procedure. @param ln: language of the page """ _ = gettext_set_language(ln) out = """ """ out += _MENU_ out += """


%s




""" % (_("A new purchase has been registered with success."), CFG_SITE_URL, _("Back to home")) return out def tmpl_ordered_books(self, ordered_books, ln=CFG_SITE_LANG): """ Display list with all ordered books. @param ordered_books: list with all the ordered books @type ordered_books: list """ _ = gettext_set_language(ln) out = """ """ out += _MENU_ out += """

"""% (_("Item"), _("Vendor"), _("Ordered date"), _("Price"), _("Status"), _("Expected date"), _("Notes"), _("Option(s)")) for (purchase_id, recid, vendor_id, ordered_date, expected_date, price, status, notes) in ordered_books: vendor_name = db.get_vendor_name(vendor_id) title_link = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/get_item_details', {'recid': recid, 'ln': ln}, (book_title_from_MARC(recid))) no_notes_link = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/get_purchase_notes', {'purchase_id': purchase_id}, (_("No notes"))) see_notes_link = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/get_purchase_notes', {'purchase_id': purchase_id}, (_("See notes"))) if notes == "": notes_link = no_notes_link else: notes_link = see_notes_link out += """ """ % (title_link, vendor_name, ordered_date, price, status, expected_date, notes_link, CFG_SITE_URL, purchase_id, _("select")) out += """
%s %s %s %s %s %s %s %s
%s %s %s %s %s %s %s


""" return out def tmpl_purchase_notes(self, purchase_notes, purchase_id, ln=CFG_SITE_LANG): """ @param purchase_notes: notes about a given purchase @type purchase_notes: dictionnary @param purchase_id: identify the purchase. Primary key of crcPURCHASE @type purchase_id: int """ _ = gettext_set_language(ln) if not purchase_notes: purchase_notes = {} else: purchase_notes = eval(purchase_notes) out = """ """ out += _MENU_ out +="""


%s
""" % (CFG_SITE_URL, purchase_id, _("Notes about acquisition")) key_array = purchase_notes.keys() key_array.sort() for key in key_array: delete_note = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/get_purchase_notes', {'delete_key': key, 'purchase_id': purchase_id, 'ln': ln}, (_("[delete]"))) out += """ """ % (key, purchase_notes[key], delete_note) out += """
%s %s %s

%s




""" % (_("Write new note"), CFG_SITE_URL, _("Back"), _("Confirm")) return out def tmpl_register_ill_request_step0(self, result, infos, key, string, recid, ln=CFG_SITE_LANG): """ @param result: borrower's information @type result: list @param infos: informations @type infos: list @param key: field (name, email, etc...) @param key: string @param string: pattern @type string: string @param recid: identify the record. Primary key of bibrec. @type recid: int @param ln: language of the page """ _ = gettext_set_language(ln) (book_title, book_year, book_author, book_isbn, book_editor) = book_information_from_MARC(int(recid)) if book_isbn: book_cover = get_book_cover(book_isbn) else: book_cover = "%s/img/book_cover_placeholder.gif" % (CFG_SITE_URL) out = self.tmpl_infobox(infos, ln) out += _MENU_ out += """

%s
""" % (_("Item details"), _("Title"), book_title, _("Author(s)"), book_author, _("Year"), book_year, _("Publisher"), book_editor, _("ISBN"), book_isbn, str(book_cover)) out += """
%s %s
%s %s
%s %s
%s %s
%s %s
Book Cover
""" % (CFG_SITE_URL, recid) if CFG_CERN_SITE == 1: out += """
Search user by """ if key == 'email': out += """ ccid name email """ elif key == 'name': out += """ ccid name email """ else: out += """ ccid name email """ else: out += """
Search borrower by """ if key == 'email': out += """ id name email """ elif key == 'id': out += """ id name email """ else: out += """ id name email """ out += """


""" % (string or '') if result: out += """
""" % (_("Select user")) out += """




""" return out def tmpl_register_ill_request_step1(self, recid, user_info, ln=CFG_SITE_LANG): """ @param recid: identify the record. Primary key of bibrec. @type recid: int @param user_info: user's informations @type user_info: tuple """ (id, ccid, name, email, phone, address, mailbox) = user_info.split(',') _ = gettext_set_language(ln) display_id=id id_string= _("ID") if CFG_CERN_SITE == 1: display_id=ccid id_string= _("CCID") out = """ """ out += _MENU_ (book_title, book_year, book_author, book_isbn, book_editor) = book_information_from_MARC(int(recid)) out += """

%s
%s %s
%s %s
%s %s
%s %s
%s %s

""" % (CFG_SITE_URL, _("Item details"), recid, user_info, _("Name"), book_title, _("Author(s)"), book_author, _("Year"), book_year, _("Publisher"), book_editor, _("ISBN"), book_isbn) out += """
%s
%s %s
%s %s
%s %s
%s %s
%s %s
%s %s

%s
%s select period of interest
%s select period of interest
%s
%s
""" % (_("Borrower details"), id_string, display_id, _("Name"), name, _("Email"), email, _("Phone"), phone, _("Address"), address, _("Mailbox"), mailbox, _("ILL request details"), _("Period of interest - From"), _("period_of_interest_from"), _("jsCal3"), _("period_of_interest_from"), _("jsCal3"), _("Period of interest - To"), _("period_of_interest_to"), _("jsCal4"), _("period_of_interest_to"), _("jsCal4"), _("Additional comments"), _("Borrower wants only this edition?")) out += """


""" % (_("Back"), _("Continue")) return out def tmpl_register_ill_request_step2(self, user_info, request_info, ln=CFG_SITE_LANG): """ @param user_info: user's informations @type user_info: tuple @param request_info: request's informations @type request_info: tuple @param ln: language of the page """ _ = gettext_set_language(ln) (recid, period_of_interest_from, period_of_interest_to, notes, only_edition) = request_info (book_title, book_year, book_author, book_isbn, book_editor) = book_information_from_MARC(int(recid)) (borrower_id, ccid, name, email, phone, address, mailbox) = user_info display_id = borrower_id id_string= _("ID") if CFG_CERN_SITE == 1: display_id=ccid id_string= _("CCID") out = """ """ out += _MENU_ out += """


%s
%s %s
%s %s
%s %s
%s %s
%s %s
%s
%s %s
%s %s
%s %s
%s %s
%s
%s %s
%s %s
%s %s
%s %s
%s %s
%s %s
""" % (CFG_SITE_URL, _("Item details"), borrower_id, _("Title"), book_title, _("Author(s)"), book_author, _("Year"), book_year, _("Publisher"), book_editor, _("ISBN"), book_isbn, _("ILL request details"), request_info, _("Period of interest - From"), period_of_interest_from, _("Period of interest - To"), period_of_interest_to, _("Additional comments"), notes, _("Only this edition"), only_edition, _("Borrower details"), id_strinf, id, _("Name"), name, _("Email"), email, _("Phone"), phone, _("Address"), address, _("Mailbox"), mailbox) out += """
""" % (_("Back"), _("Continue")) return out def tmpl_register_ill_request_step3(self, ln=CFG_SITE_LANG): """ Last step of the request procedure. @param ln: language of the page """ _ = gettext_set_language(ln) out = """ """ out += _MENU_ out += """


%s




""" % (_("A new ILL request has been registered with success."), CFG_SITE_URL, _("Back to home")) return out def tmpl_ill_request_with_recid(self, recid, infos, ln=CFG_SITE_LANG): """ @param recid: identify the record. Primary key of bibrec. @type recid: int @param infos: informations @type infos: list """ _ = gettext_set_language(ln) out = self.tmpl_infobox(infos, ln) (book_title, book_year, book_author, book_isbn, book_editor) = book_information_from_MARC(int(recid)) today = datetime.date.today() within_six_months = (datetime.date.today() + datetime.timedelta(days=182)).strftime('%Y-%m-%d') out += """

%s

%s
%s %s
%s %s
%s %s
%s %s
%s %s


""" % (CFG_SITE_URL, recid, _('Interlibrary loan request for books'), _("Item details"), recid, _("Name"), book_title, _("Author(s)"), book_author, _("Year"), book_year, _("Publisher"), book_editor, _("ISBN"), book_isbn) conditions_link = """conditions""" out += """ """% (CFG_SITE_URL, CFG_SITE_URL) out += """
%s
%s
%s
%s
%s
%s



""" % (_("ILL request details"), _("Period of interest - From"), CFG_SITE_URL, today, _("Period of interest - To"), CFG_SITE_URL, within_six_months, _("Additional comments"), _("I accept the %s of the service in particular the return of books in due time." % (conditions_link)), _("I want this edition only."), _("Back"), _("Continue")) return out def tmpl_ill_register_request_with_recid(self, message, ln=CFG_SITE_LANG): """ @param message: information to the borrower @type message: string @param ln: language of the page """ _ = gettext_set_language(ln) out = """

%s
%s%s%s




""" % (message, _("You can see your loans "), CFG_SITE_URL + '/yourloans/display', _("here"), _("."), CFG_SITE_URL, _("Back to home")) return out def tmpl_display_ill_form(self, infos, ln=CFG_SITE_LANG): """ @param infos: informations @type infos: list """ _ = gettext_set_language(ln) out = self.tmpl_infobox(infos, ln) out += """
%s
%s
%s
%s
%s
%s
%s
%s

""" % (CFG_SITE_URL, _("Item details"), _("Title"), _("Author(s)"), _("Place"), _("Publisher"), _("Year"), _("Edition"), _("ISBN")) conditions_link = """conditions""" out += """
%s
%s select period of interest
%s select period of interest
%s
%s
%s



""" % (_("ILL request details"), _("Period of interest - From"), _("period_of_interest_from"), _("jsCal1"), _("period_of_interest_from"), _("jsCal1"), _("Period of interest - To"), _("period_of_interest_to"), _("jsCal2"), _("period_of_interest_to"), _("jsCal2"), _("Additional comments"), _("I accept the %s of the service in particular the return of books in due time." % (conditions_link)), _("I want this edition only."), _("Back"), _("Continue")) return out def tmpl_list_ill_request(self, ill_req, ln=CFG_SITE_LANG): """ @param ill_req: informations about a given ILL request @type ill_req: tuple """ _ = gettext_set_language(ln) out = """ """ out += _MENU_ out += """

"""% (_("Borrower"), _("Item"), _("Supplier"), _("Status"), _("ID"), _("Interest from"), _("Type"), _("Option(s)")) for (ill_request_id, borrower_id, borrower_name, library_id, ill_status, period_from, _period_to, item_info, request_type) in ill_req: borrower_link = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/get_borrower_details', {'borrower_id': borrower_id, 'ln': ln}, (borrower_name)) if library_id: library_name = db.get_library_name(library_id) else: library_name = '-' item_info = eval(item_info) try: title_link = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/get_item_details', {'recid': item_info['recid'], 'ln': ln}, (book_title_from_MARC(int(item_info['recid'])))) except KeyError: if request_type == 'book': title_link = item_info['title'] else: title_link = item_info['periodical_title'] out += """ """ % (borrower_link, title_link, library_name, ill_status,ill_request_id, period_from, request_type, CFG_SITE_URL, ill_request_id, _('select')) out += """
%s %s %s %s %s %s %s %s
%s %s %s %s %s %s %s
""" return out def tmpl_ill_request_details_step1(self, ill_request_id, ill_request_details, libraries, ill_request_borrower_details,ln=CFG_SITE_LANG): """ @param ill_request_id: identify the ILL request. Primary key of crcILLREQUEST @type ill_request_id: int @param ill_req_details: informations about a given ILL request @type ill_req_details: tuple @param libraries: list of libraries @type libraries: list @param ill_status: status of an ILL request @type ill_status: string @param ill_request_borrower_details: borrower's informations @type ill_request_borrower_details: tuple """ _ = gettext_set_language(ln) out = _MENU_ out += """ """% (CFG_SITE_URL, CFG_SITE_URL) (_borrower_id, borrower_name, borrower_email, borrower_mailbox, period_from, period_to, item_info, borrower_comments, only_this_edition, request_type) = ill_request_borrower_details (library_id, request_date, expected_date, arrival_date, due_date, return_date, cost, barcode, library_notes, ill_status) = ill_request_details if cost: (value, currency) = cost.split() else: (value, currency) = (0, 'EUR') if library_notes == '' or library_notes == None: previous_library_notes = {} else: previous_library_notes = eval(library_notes) key_array = previous_library_notes.keys() key_array.sort() item_info = eval(item_info) today = datetime.date.today() within_a_week = (datetime.date.today() + datetime.timedelta(days=7)).strftime('%Y-%m-%d') within_a_month = (datetime.date.today() + datetime.timedelta(days=30)).strftime('%Y-%m-%d') notes='' for key in key_array: delete_note = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/ill_request_details_step1', {'delete_key': key, 'ill_request_id': ill_request_id, 'ln': ln}, (_("[delete]"))) notes += """ %s %s %s """ % (key, previous_library_notes[key], delete_note) if library_id: library_name = db.get_library_name(library_id) else: library_name = '-' try: (book_title, book_year, book_author, book_isbn, book_editor) = book_information_from_MARC(int(item_info['recid'])) if book_isbn: book_cover = get_book_cover(book_isbn) else: book_cover = "%s/img/book_cover_placeholder.gif" % (CFG_SITE_URL) out += """

%s
%s %s
%s %s
%s %s
%s %s
%s %s
Book Cover

""" % (CFG_SITE_URL, ill_request_id, _("Item details"), _("Name"), book_title, _("Author(s)"), book_author, _("Year"), book_year, _("Publisher"), book_editor, _("ISBN"), book_isbn, str(book_cover)) except KeyError: try: book_cover = get_book_cover(item_info['isbn']) except KeyError: book_cover = "%s/img/book_cover_placeholder.gif" % (CFG_SITE_URL) f=open("/tmp/item_info",'w') f.write(str(item_info)+'\n') f.close() if str(request_type) == 'book': out += """

%s
%s %s
%s %s
%s %s
%s %s
%s %s
%s %s
%s %s
Book Cover

""" % (CFG_SITE_URL, ill_request_id, _("Item details"), _("Title"), item_info['title'], _("Author(s)"), item_info['authors'], _("Place"), item_info['place'], _("Publisher"), item_info['publisher'], _("Year"), item_info['year'], _("Edition"), item_info['edition'], _("ISBN"), item_info['isbn'], str(book_cover)) # for articles elif str(request_type) == 'article': out += """

%s
%s %s
%s %s
%s %s
%s %s
%s %s
%s %s
%s %s
%s %s
Book Cover

""" % (CFG_SITE_URL, ill_request_id, _("Item details"), _("Periodical Title"), item_info['periodical_title'], _("Article Title"), item_info['title'], _("Author(s)"), item_info['authors'], _("Volume, Issue, Page"), item_info['volume'], _("ISSN"), item_info['issn'], _("Place"), item_info['place'], _("Publisher"), item_info['publisher'], _("Year"), item_info['year'], str(book_cover)) else: out+= """aqui falta algo, no?""" out += """
%s
%s %s
%s %s
%s %s
%s %s
%s %s
%s %s
%s %s
%s
""" % (_("Borrower request"), _("Name"), borrower_name, _("Email"), borrower_email, _("Mailbox"), borrower_mailbox, _("Period of interest (From)"), period_from, _("Period of interest (To)"), period_to, _("Borrower comments"), borrower_comments or '-', _("Only this edition?"), only_this_edition or 'No', _("ILL request details")) #### NEW #### if ill_status == 'new' or ill_status == None or ill_status == '': if request_type == 'book': out += """
%s
%s %s
%s """ % (_("Status"), ill_request_id, ill_request_id, ill_request_id, ill_request_id, _("ILL request ID"), ill_request_id, _("Previous notes")) if request_type == 'article': out += """
%s
%s %s
%s """ % (_("Status"), ill_request_id, ill_request_id, ill_request_id, _("ILL request ID"), ill_request_id, _("Previous notes")) out += notes out += """
%s
""" % (_("Library notes")) ############# REQUESTED ############## elif ill_status == 'requested': if request_type == 'book': out += """
%s
%s %s
%s
%s
%s %s
%s
%s
%s
%s
%s
%s """ %(_("Barcode"), barcode or 'No barcode asociated', _("Previous notes")) out += notes out += """
%s
""" % (_("Library notes")) ##### ON LOAN ############## elif ill_status == 'on loan': out += """ """ % (_("Status"), ill_request_id, ill_request_id, ill_request_id, ill_request_id, _("ILL request ID"), ill_request_id, _("Library"), library_name, _("Request date"), request_date, _("Expected date"), expected_date) if str(arrival_date)=='0000-00-00': date1=today else: date1=arrival_date if str(due_date)=='0000-00-00': date2=within_a_month else: date2=due_date out += """ """ % (_("Arrival date"), CFG_SITE_URL, date1, _("Due date"), CFG_SITE_URL, date2, request_date, expected_date) out += """
%s
%s %s
%s %s
%s %s
%s %s
%s
%s
%s
%s
%s """ % (_("Barcoce"), barcode, _("Previous notes")) out += notes out += """
%s
""" % (_("Library notes")) ##### RETURNED ############## elif ill_status == 'returned': out += """
%s
%s %s
%s %s
%s %s
%s %s
%s %s
%s %s
%s
%s
%s %s
%s """ % (_("Barcode"), barcode, _("Previous notes")) out += notes out += """
%s
""" % (_("Library notes")) ##### RECEIVED ############## elif ill_status == 'received': if str(arrival_date)=='0000-00-00': date1=today else: date1=arrival_date out += """
%s
%s %s
%s %s
%s %s
%s %s
%s
%s
%s %s
%s """ % (_("Barcode"), barcode, _("Previous notes")) out += notes out += """
%s
""" % (_("Library notes")) ###### END STATUSES ###### out += """


""" % (_("Back"), _("Continue")) return out def tmpl_ill_request_details_step2(self, ill_req_details, request_info, ill_status, ill_request_borrower_details, ln=CFG_SITE_LANG): """ @param ill_req_details: informations about a given ILL request @type ill_req_details: tuple @param request_info: @type request_info: tuple @param ill_status: status of an ILL request @type ill_status: string @param ill_request_borrower_details: borrower's informations @type ill_request_borrower_details: tuple """ _ = gettext_set_language(ln) out = _MENU_ (_borrower_id, borrower_name, borrower_email, borrower_mailbox, period_from, period_to, book_info, borrower_comments, only_this_edition) = ill_request_borrower_details book_info = eval(book_info) try: (book_title, book_year, book_author, book_isbn, book_editor) = book_information_from_MARC(int(book_info['recid'])) if book_isbn: book_cover = get_book_cover(book_isbn) else: book_cover = "%s/img/book_cover_placeholder.gif" % (CFG_SITE_URL) out += """

%s
%s %s
%s %s
%s %s
%s %s
%s %s
Book Cover

""" % (CFG_SITE_URL, request_info, _("Item details"), _("Name"), book_title, _("Author(s)"), book_author, _("Year"), book_year, _("Publisher"), book_editor, _("ISBN"), book_isbn, str(book_cover)) except KeyError: try: book_cover = get_book_cover(book_info['isbn']) except KeyError: book_cover = "%s/img/book_cover_placeholder.gif" % (CFG_SITE_URL) out += """

%s
%s %s
%s %s
%s %s
%s %s
%s %s
%s %s
%s %s
Book Cover

""" % (CFG_SITE_URL, request_info, _("Item details"), _("Name"), book_info['title'], _("Author(s)"), book_info['authors'], _("Place"), book_info['place'], _("Publisher"), book_info['publisher'], _("Year"), book_info['year'], _("Edition"), book_info['edition'], _("ISBN"), book_info['isbn'], str(book_cover)) out += """
%s
%s %s
%s %s
%s %s
%s %s
%s %s
%s %s
%s %s
%s
""" % (_("Borrower request"), _("Name"), borrower_name, _("Email"), borrower_email, _("Mailbox"), borrower_mailbox, _("Period of interest - From"), period_from, _("Period of interest - To"), period_to, _("Borrower comments"), borrower_comments or '-', _("Only this edition?"), only_this_edition, _("ILL request details")) if ill_status == 'new': if not ill_req_details: previous_library_notes = {} else: previous_library_notes = eval(ill_req_details[8]) (ill_request_id, library_notes) = request_info out += """
%s %s
%s %s
%s """ % (ill_status, _("Status"), ill_status, _("ILL request ID"), ill_request_id, _("Previous notes")) key_array = previous_library_notes.keys() key_array.sort() for key in key_array: delete_note = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/ill_request_details_step2', {'delete_key': key, 'ill_request_id': ill_request_id, 'ill_status': ill_status, 'library_notes': library_notes, 'ln': ln}, (_("[delete]"))) out += """ """ % (key, previous_library_notes[key], delete_note) out += """
%s %s %s
%s %s
""" % (_("Library notes"), library_notes or '-') elif ill_status == 'requested': if not ill_req_details: previous_library_notes = {} else: previous_library_notes = eval(ill_req_details[8]) (ill_request_id, library_id, request_date, expected_date, cost, currency, barcode, library_notes) = request_info if library_id: library_name = db.get_library_name(library_id) else: library_name = '-' out += """
%s %s
%s %s
%s %s
%s %s
%s %s
%s %s %s
%s %s
%s """ % (ill_status, _("Status"), ill_status, _("ILL request ID"), ill_request_id, _("Library/Supplier"), library_name, _("Request date"), request_date, _("Expected date"),expected_date, _("Cost"), cost, currency, _("Barcode"), barcode, _("Previous notes")) key_array = previous_library_notes.keys() key_array.sort() for key in key_array: delete_note = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/ill_request_details_step2', {'delete_key': key, 'ill_request_id': ill_request_id, 'ill_status': ill_status, 'library_notes': library_notes, 'ln': ln}, (_("[delete]"))) out += """ """ % (key, previous_library_notes[key], delete_note) out += """
%s %s %s
%s %s
""" % (_("Library notes"), library_notes or '-') elif ill_status == 'request cancelled': (library_id, request_date, expected_date, previous_library_notes) = ill_req_details if not previous_library_notes: previous_library_notes = {} else: previous_library_notes = eval(previous_library_notes) (ill_request_id, cost, currency, barcode, library_notes) = request_info if library_id: library_name = db.get_library_name(library_id) else: library_name = '-' out += """
%s %s
%s %s
%s %s
%s %s
%s %s
%s %s %s
%s %s
%s """ % (ill_status, _("Status"), ill_status, _("ILL request ID"), ill_request_id, _("Library/Supplier"), library_name, _("Request date"), request_date, _("Expected date"),expected_date, _("Cost"), cost, currency, _("Barcode"), barcode, _("Previous notes")) key_array = previous_library_notes.keys() key_array.sort() for key in key_array: delete_note = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/ill_request_details_step2', {'delete_key': key, 'ill_request_id': ill_request_id, 'ill_status': ill_status, 'library_notes': library_notes, 'ln': ln}, (_("[delete]"))) out += """ """ % (key, previous_library_notes[key], delete_note) out += """
%s %s %s
%s %s
""" % (_("Library notes"), library_notes or '-') elif ill_status == 'item received, due date defined': (library_id, request_date, expected_date, previous_library_notes) = ill_req_details if not previous_library_notes: previous_library_notes = {} else: previous_library_notes = eval(previous_library_notes) (ill_request_id, arrival_date, due_date, cost, currency, barcode, library_notes) = request_info if library_id: library_name = db.get_library_name(library_id) else: library_name = '-' out += """
%s %s
%s %s
%s %s
%s %s
%s %s
%s %s
%s %s
%s %s %s
%s %s
%s """ % (ill_status, _("Status"), ill_status, _("ILL request ID"), ill_request_id, _("Library/Supplier"), library_name, _("Request date"), request_date, _("Expected date"), expected_date, _("Arrival date"), arrival_date, _("Due date"), due_date, _("Cost"), cost, currency, _("Barcode"), barcode, _("Previous notes")) key_array = previous_library_notes.keys() key_array.sort() for key in key_array: delete_note = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/ill_request_details_step2', {'delete_key': key, 'ill_request_id': ill_request_id, 'ill_status': ill_status, 'library_notes': library_notes, 'ln': ln}, (_("[delete]"))) out += """ """ % (key, previous_library_notes[key], delete_note) out += """
%s %s %s
%s %s
""" % (_("Library notes"), library_notes or '-') elif ill_status == 'item returned': (library_id, request_date, expected_date, arrival_date, due_date, barcode, previous_library_notes) = ill_req_details previous_library_notes = eval(previous_library_notes) (ill_request_id, return_date, cost, currency, library_notes) = request_info library_name = db.get_library_name(library_id) out += """
%s %s
%s %s
%s %s
%s %s
%s %s
%s %s
%s %s
%s %s
%s %s %s
%s %s
%s """ % (ill_status, _("Status"), ill_status, _("ILL request ID"), ill_request_id, _("Library/Supplier"), library_name, _("Request date"), request_date, _("Expected date"), expected_date, _("Arrival date"), arrival_date, _("Due date"), due_date, _("Return date"), return_date, _("Cost"), cost, currency, _("Barcode"), barcode, _("Previous notes")) key_array = previous_library_notes.keys() key_array.sort() for key in key_array: delete_note = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/ill_request_details_step2', {'delete_key': key, 'ill_request_id': ill_request_id, 'ill_status': ill_status, 'library_notes': library_notes, 'ln': ln}, (_("[delete]"))) out += """ """ % (key, previous_library_notes[key], delete_note) out += """
%s %s %s
%s %s
""" % (_("Library notes"), library_notes or '-') else: (library_id, request_date, expected_date, arrival_date, due_date, return_date, cost, barcode, previous_library_notes) = ill_req_details previous_library_notes = eval(previous_library_notes) (value, currency) = cost.split() (ill_request_id, library_notes) = request_info library_name = db.get_library_name(library_id) out += """
%s %s
%s %s
%s %s
%s %s
%s %s
%s %s
%s %s
%s %s
%s %s %s
%s %s
%s """ % (ill_status, _("Status"), ill_status, _("ILL request ID"), ill_request_id, _("Library/Supplier"), library_name, _("Request date"), request_date, _("Expected date"), expected_date, _("Arrival date"), arrival_date, _("Due date"), due_date, _("Return date"), return_date, _("Cost"), value, currency, _("Barcode"), barcode, _("Previous notes")) key_array = previous_library_notes.keys() key_array.sort() for key in key_array: delete_note = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/ill_request_details_step2', {'delete_key': key, 'ill_request_id': ill_request_id, 'ill_status': ill_status, 'library_notes': library_notes, 'ln': ln}, (_("[delete]"))) out += """ """ % (key, previous_library_notes[key], delete_note) out += """
%s %s %s
%s %s
""" % (_("Library notes"), library_notes or '-') out += """


""" % (_("Back"), _("Continue")) return out def tmpl_ill_request_details_step3(self, ln=CFG_SITE_LANG): """ Last step of the request procedure. @param ln: language of the page """ _ = gettext_set_language(ln) out = """ """ out += _MENU_ out += """


%s




""" % (_("An ILL request has been updated with success."), CFG_SITE_URL, _("Back to home")) return out def tmpl_ordered_book_details_step1(self, order_details, list_of_vendors, ln=CFG_SITE_LANG): """ @param order_details: informations about a given order. @type order_details: tuple @param list_of_vendors: list with all the vendors @type list_of_vendors: list """ _ = gettext_set_language(ln) out = """ """ out += _MENU_ (purchase_id, recid, vendor, order_date, expected_date, price, status, notes) = order_details purchase_notes = eval(notes) (book_title, book_year, book_author, book_isbn, book_editor) = book_information_from_MARC(int(recid)) (value, currency) = price.split() if book_isbn: book_cover = get_book_cover(book_isbn) else: book_cover = "%s/img/book_cover_placeholder.gif" % (CFG_SITE_URL) out += """

%s
%s %s
%s %s
%s %s
%s %s
%s %s
Book Cover

""" % (CFG_SITE_URL, purchase_id, _("Item details"), recid, _("Name"), book_title, _("Author(s)"), book_author, _("Year"), book_year, _("Publisher"), book_editor, _("ISBN"), book_isbn, str(book_cover)) out += """
%s
%s
%s
%s
%s
%s
%s """ % (_("Order date"), CFG_SITE_URL, order_date, _("Expected date"), CFG_SITE_URL, expected_date, _("Previous notes")) key_array = purchase_notes.keys() key_array.sort() for key in key_array: delete_note = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/ordered_books_details_step1', {'delete_key': key, 'purchase_id': purchase_id, 'ln': ln}, (_("[delete]"))) out += """ """ % (key, purchase_notes[key], delete_note) out += """
%s %s %s
%s



""" % (purchase_notes, _("Notes"), _("Back"), _("Continue")) return out def tmpl_ordered_book_details_step2(self, order_details, ln=CFG_SITE_LANG): """ @param order_details: informations about a given order. @type order_details: tuple @param ln: language of the page """ (purchase_id, recid, vendor_id, cost, currency, status, order_date, expected_date, purchase_notes, library_notes) = order_details vendor_name = db.get_vendor_name(vendor_id) (book_title, book_year, book_author, book_isbn, book_editor) = book_information_from_MARC(int(recid)) if book_isbn: book_cover = get_book_cover(book_isbn) else: book_cover = "%s/img/book_cover_placeholder.gif" % (CFG_SITE_URL) _ = gettext_set_language(ln) out = """ """ out += _MENU_ out += """

%s
%s %s
%s %s
%s %s
%s %s
%s %s
Book Cover

""" % (CFG_SITE_URL, purchase_id, recid, vendor_id, cost, currency, status, order_date, expected_date, purchase_notes, library_notes, _("Item details"), _("Name"), book_title, _("Author(s)"), book_author, _("Year"), book_year, _("Publisher"), book_editor, _("ISBN"), book_isbn, str(book_cover)) out += """
%s
%s %s
%s %s %s
%s %s
%s %s
%s %s
%s """ % (_("Order details"), _("Vendor"), vendor_name, _("Price"), cost, currency, _("Status"), status, _("Order date"), order_date, _("Expected date"), expected_date, _("Previous notes")) purchase_notes = eval(purchase_notes) key_array = purchase_notes.keys() key_array.sort() for key in key_array: out += """ """ % (key, purchase_notes[key]) out += """
[%s] %s
%s %s



""" % (_("Notes"), library_notes, _("Back"), _("Continue")) return out def tmpl_ordered_book_details_step3(self, ln=CFG_SITE_LANG): """ Last step of the request procedure. @param ln: language """ _ = gettext_set_language(ln) out = """ """ out += _MENU_ out += """


%s




""" % (_("Purchase information updated with success."), CFG_SITE_URL, _("Back to home")) return out def tmpl_add_new_vendor_step1(self, ln=CFG_SITE_LANG): """ @param ln: language """ _ = gettext_set_language(ln) out = """ """ out += _MENU_ out += """


%s
%s
%s
%s
%s
%s



""" % (CFG_SITE_URL, _("New vendor information"), _("Name"), _("Email"), _("Phone"), _("Address"), _("Notes"), _("Back"), _("Continue")) return out def tmpl_add_new_vendor_step2(self, tup_infos, ln=CFG_SITE_LANG): """ @param tup_infos: borrower's informations @type tup_infos: tuple @param ln: language """ _ = gettext_set_language(ln) (name, email, phone, address, notes) = tup_infos out = """ """ out += _MENU_ out += """


%s
%s %s
%s %s
%s %s
%s %s
%s %s



""" % (CFG_SITE_URL, _("New vendor information"), _("Name"), name, _("Email"), email, _("Phone"), phone, _("Address"), address, _("Notes"), notes, _("Back"), _("Confirm"), tup_infos) return out def tmpl_add_new_vendor_step3(self, ln=CFG_SITE_LANG): """ @param ln: language """ _ = gettext_set_language(ln) out = """ """ out += _MENU_ out += """


%s



""" % (_("A new vendor has been registered."), _("Back to home"), CFG_SITE_URL) return out def tmpl_update_vendor_info_step1(self, infos, ln=CFG_SITE_LANG): """ @param infos: informations @type infos: list @param ln: language """ _ = gettext_set_language(ln) out = self.tmpl_infobox(infos, ln) out += _MENU_ out += """



%s name email






""" % (CFG_SITE_URL, _("Search vendor by"), _("Back")) return out def tmpl_update_vendor_info_step2(self, result, ln=CFG_SITE_LANG): """ @param result: search result @type result: list @param ln: language """ _ = gettext_set_language(ln) out = """ """ out += _MENU_ out += """

%s vendor(s) found

""" % (len(result), _("Vendor(s)")) for (vendor_id, name) in result: vendor_link = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/update_vendor_info_step3', {'vendor_id': vendor_id, 'ln': ln}, (name)) out += """ """ % (vendor_link, vendor_id) out += """
%s
%s

""" out += """



""" % (_("Back")) return out def tmpl_update_vendor_info_step3(self, vendor_info, ln=CFG_SITE_LANG): """ @param vendor_infos: information about a given vendor @type vendor_infos: tuple """ _ = gettext_set_language(ln) (vendor_id, name, address, email, phone, _notes) = vendor_info out = """ """ out += _MENU_ out += """


%s
%s
%s
%s
%s



""" % (CFG_SITE_URL, vendor_id, _("Vendor information"), _("Name"), name, _("Email"), email, _("Phone"), phone, _("Address"), address, _("Back"), _("Continue")) return out def tmpl_update_vendor_info_step4(self, tup_infos, ln=CFG_SITE_LANG): """ @param tup_infos: information about a given vendor @type tup_infos: tuple """ (_vendor_id, name, email, phone, address) = tup_infos _ = gettext_set_language(ln) out = """ """ out += _MENU_ out += """


%s
%s %s
%s %s
%s %s
%s %s



""" % (CFG_SITE_URL, _("Vendor information"), _("Name"), name, _("Email"), email, _("Phone"), phone, _("Address"), address, _("Back"), _("Continue"), tup_infos) return out def tmpl_update_vendor_info_step5(self, ln=CFG_SITE_LANG): """ @param ln: language """ _ = gettext_set_language(ln) out = """ """ out += _MENU_ out += """


%s



""" % (_("The information has been updated."), _("Back to home"), CFG_SITE_URL) return out def tmpl_search_vendor_step1(self, infos, ln=CFG_SITE_LANG): """ @param infos: informations @type infos: list @param ln: language """ _ = gettext_set_language(ln) out = self.tmpl_infobox(infos, ln) out += _MENU_ out += """



%s name email






""" % (CFG_SITE_URL, _("Search vendor by"), _("Back"), _("Search")) return out def tmpl_search_vendor_step2(self, result, ln=CFG_SITE_LANG): """ @param result: search result @type result:list @param ln: language """ _ = gettext_set_language(ln) out = """ """ out += _MENU_ out += """

%s vendor(s) found

""" % (len(result), _("Vendor(s)")) for (vendor_id, name) in result: vendor_link = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/get_vendor_details', {'vendor_id': vendor_id, 'ln': ln}, (name)) out += """ """ % (vendor_link, vendor_id) out += """
%s
%s




""" % (_("Back")) return out def tmpl_vendor_details(self, vendor_details, ln=CFG_SITE_LANG): """ @param vendor_details: details about a given vendor @type vendor_details: tuple @param ln: language of the page """ _ = gettext_set_language(ln) out = """ """ out += _MENU_ out += """

""" (vendor_id, name, address, email, phone, notes) = vendor_details no_notes_link = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/get_vendor_notes', {'vendor_id': vendor_id}, (_("No notes"))) see_notes_link = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/get_vendor_notes', {'vendor_id': vendor_id}, (_("Notes about this vendor"))) if notes == "": notes_link = no_notes_link else: notes_link = see_notes_link out += """
%s
%s %s
%s %s
%s %s
%s %s
%s %s
""" % (_("Vendor details"), _("Name"), name, _("Address"), address, _("Email"), email, _("Phone"), phone, _("Notes"), notes_link, CFG_SITE_URL, vendor_id, _("Update")) out += """




""" % (_("Back")) return out def tmpl_vendor_notes(self, vendor_notes, vendor_id, add_notes, ln=CFG_SITE_LANG): _ = gettext_set_language(ln) out = """ """ out += _MENU_ out +="""


""" % (CFG_SITE_URL, _("Notes about this vendor")) notes = vendor_notes.split('\n') for values in notes: out += """ """ % (values) if add_notes: out += """
%s
%s
""" % (_("Confirm"), vendor_id) else: out += """ """ % (_("Add notes"), vendor_id) out += """




""" % (CFG_SITE_URL, vendor_id, _("Back")) return out def tmpl_register_ill_request_with_no_recid_step1(self, infos, ln=CFG_SITE_LANG): """ @param infos: informations @type infos: list """ _ = gettext_set_language(ln) out = self.tmpl_infobox(infos, ln) out += _MENU_ out += """

%s
%s


%s
%s
%s
%s
%s
%s
%s
%s

""" % (_("Book does not exists on CDS Invenio."),_("Please fill the following form."), CFG_SITE_URL, _("Item details"), _("Book title"), _("Author(s)"), _("Place"), _("Publisher"), _("Year"), _("Edition"), _("ISBN")) conditions_link = """conditions""" out += """
%s
"""% (CFG_SITE_URL, CFG_SITE_URL, _("ILL request details"), _("Period of interest (From)"), CFG_SITE_URL, datetime.date.today().strftime('%Y-%m-%d')) out += """
%s
%s
%s
%s



""" % (_("Period of interest (To)"), CFG_SITE_URL, (datetime.date.today() + datetime.timedelta(days=365)).strftime('%Y-%m-%d'), _("Additional comments"), _("Borrower accepts the %s of the service in particular the return of books in due time." % (conditions_link)), _("Borrower wants this edition only."), _("Back"), _("Continue")) return out def tmpl_register_ill_request_with_no_recid_step2(self, book_info, request_details, result, key, string, infos, ln): """ @param book_info: book's informations @type book_info: tuple @param request_details: details about a given request @type request_details: tuple @param result: borrower's informations @type result: list @param key: field (name, email, etc...) @param key: string @param string: pattern @type string: string @param infos: informations @type infos: list """ (title, authors, place, publisher, year, edition, isbn) = book_info (period_of_interest_from, period_of_interest_to, additional_comments, only_edition)= request_details _ = gettext_set_language(ln) out = self.tmpl_infobox(infos, ln) out += _MENU_ #if isbn: # book_cover = get_book_cover(isbn) #else: # book_cover = "%s/img/book_cover_placeholder.gif" % (CFG_SITE_URL) out += """

""" % (CFG_SITE_URL, _("Item details"), _("Name"), title, title, _("Author(s)"), authors, authors, _("Place"), place, place, _("Year"), year, year, _("Publisher"), publisher, publisher, _("Edition"), edition, edition, _("ISBN"), isbn, isbn, _("ILL request details"), _("Period of interest - From"), period_of_interest_from, period_of_interest_from, _("Period of interest - To"), period_of_interest_to, period_of_interest_to, _("Additional comments"), additional_comments, additional_comments, _("Only this edition."), only_edition, only_edition) #Book Cover , # str(book_cover) out += """
%s
%s %s
%s %s
%s %s
%s %s
%s %s
%s %s
%s %s
%s
%s %s
%s %s
%s %s
%s %s
""" if CFG_CERN_SITE == 1: out += """
Search user by """ if key == 'email': out += """ ccid name email """ elif key == 'name': out += """ ccid name email """ else: out += """ ccid name email """ else: out += """
Search borrower by """ if key == 'email': out += """ id name email """ elif key == 'id': out += """ id name email """ else: out += """ id name email """ out += """


""" % (string or '') if result: out += """
""" % (_("Select user"), request_details) out += """




""" return out def tmpl_register_ill_request_with_no_recid_step3(self, book_info, user_info, request_details, ln): """ @param book_info: book's informations @type book_info: tuple @param user_info: user's informations @type user_info: tuple @param request_details: details about a given request @type request_details: tuple """ _ = gettext_set_language(ln) (title, authors, place, publisher, year, edition, isbn) = book_info (borrower_id, ccid, name, email, phone, address, mailbox) = user_info display_id = borrower_id id_string= _("ID") if CFG_CERN_SITE == 1: display_id=ccid id_string= _("CCID") (period_of_interest_from, period_of_interest_to, additional_comments, only_edition)= request_details out = _MENU_ out += """

""" % (CFG_SITE_URL, book_info, request_details, _("Item details"), _("Title"), title, _("Author(s)"), authors, _("Place"), place, _("Year"), year, _("Publisher"), publisher, _("Edition"), edition, _("ISBN"), isbn, _("ILL request details"), _("Period of interest (From)"), period_of_interest_from, _("Period of interest (To)"), period_of_interest_to, _("Additional comments"), additional_comments, _("Only this edition"), only_edition) out += """
%s
%s %s
%s %s
%s %s
%s %s
%s %s
%s %s
%s %s
%s
%s %s
%s %s
%s %s
%s %s
%s
%s %s
%s %s
%s %s
%s %s
%s %s
%s %s
""" % (_("Borrower details"), user_info, id_string, display_id, _("Name"), name, _("Email"), email, _("Phone"), phone, _("Address"), address, _("Mailbox"), mailbox) #out += """ # #
# #
# # # # # # #
# # # # # #
%s
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
%s%s
%s%s
%s%s
%s%s
%s%s
%s%s
%s%s
# """ %(CFG_SITE_URL, # _("Item details"), book_info, # _("Name"), title, # _("Author(s)"), authors, # _("Place"), place, # _("Year"), year, # _("Publisher"), publisher, # _("Edition"), edition, # _("ISBN"), isbn,) #out += """ # # # # # #
%s
# # # # # # # # # # # # # # # # # #
%s%s
%s%s
%s%s
%s%s
#
# # # # #
# #
#
# # # # # # #
%s
# # # # # # # # # # # # # # # # # # # # # #
%s%s
%s%s
%s%s
%s%s
%s%s
# #
# """ % ( # _("ILL request details"), request_details, # _("Period of interest - From"), period_of_interest_from, # _("Period of interest - To"), period_of_interest_to, # _("Additional comments"), additional_comments, # _("Only this edition"), only_edition, # _("Borrower details"), user_info, # _("Name"), name, # _("Email"), email, # _("Phone"), phone, # _("Address"), address, # _("Mailbox"), mailbox) out += """
""" % (_("Back"), _("Continue")) return out def tmpl_borrower_ill_details(self, result, borrower_id, ln=CFG_SITE_LANG): """ @param result: ILL request's informations: @type result: list @param borrower_id: identify the borrower. Primary key of crcBORROWER. @type borrower_id: int @param ill_id: identify the ILL request. Primray key of crcILLREQUEST @type ill_id: int @param ln: language of the page """ _ = gettext_set_language(ln) out = """ """ out += _MENU_ out += """

"""% (_("ILL ID"), _("Item"), _("Supplier"), _("Request date"), _("Expected date"), _("Arrival date"), _("Due date"), _("Status"), _("Library notes")) for (ill_id, book_info, supplier_id, request_date, expected_date, arrival_date, due_date, status, library_notes) in result: #get supplier name if supplier_id: library_name = db.get_library_name(supplier_id) library_link = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/get_library_details', {'library_id': supplier_id, 'ln': ln}, (library_name)) else: library_link = '-' #get book title book_info = eval(book_info) try: title_link = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/get_item_details', {'recid': book_info['recid'], 'ln': ln}, (book_title_from_MARC(int(book_info['recid'])))) except KeyError: title_link = book_info['title'] try: ill_id_link = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/ill_request_details_step1', {'ill_request_id': str(ill_id), 'ln': ln}, str(ill_id)) except KeyError: title_link = book_info['title'] # links to notes pages lib_no_notes_link = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/get_ill_library_notes', {'ill_id': ill_id}, (_("No notes"))) lib_see_notes_link = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/get_ill_library_notes', {'ill_id': ill_id}, (_("Notes about this ILL"))) if library_notes == "": notes_link = lib_no_notes_link else: notes_link = lib_see_notes_link out += """ """ % (ill_id_link, title_link, library_link, request_date, expected_date, arrival_date, due_date, status, notes_link) out += """
%s %s %s %s %s %s %s %s %s
%s %s %s %s %s %s %s %s %s


""" % (CFG_SITE_URL, borrower_id, _("Back")) return out def tmpl_ill_notes(self, ill_notes, ill_id, ln=CFG_SITE_LANG): """ @param ill_notes: notes about an ILL request @type ill_notes: dictionnary @param ill_id: identify the ILL request. Primray key of crcILLREQUEST @type ill_id: int """ _ = gettext_set_language(ln) if not ill_notes: ill_notes = {} else: ill_notes = eval(ill_notes) out = """ """ out += _MENU_ out +="""


%s
""" % (CFG_SITE_URL, ill_id, _("Notes about acquisition")) key_array = ill_notes.keys() key_array.sort() for key in key_array: delete_note = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/get_ill_library_notes', {'delete_key': key, 'ill_id': ill_id, 'ln': ln}, (_("[delete]"))) out += """ """ % (key, ill_notes[key], delete_note) out += """
%s %s %s

%s




""" % (_("Write new note"), CFG_SITE_URL, _("Back"), _("Confirm")) return out def tmpl_get_expired_loans_with_requests(self, result, ln=CFG_SITE_LANG): """ @param result: loans' informations: @param result: list """ _ = gettext_set_language(ln) out = """ """ out += _MENU_ if len(result) == 0: out += """




%s




""" % (_("No more requests are pending or waiting."), CFG_SITE_URL, _("Back to home")) else: out += """


"""% (_("Name"), _("Item"), _('Library'), _("Location"), _("From"), _("To"), _("Request date"), _("Actions")) for (request_id, recid, borrower_id, library_id, location, date_from, date_to, request_date) in result: borrower_name = db.get_borrower_name(borrower_id) library_name = db.get_library_name(library_id) title_link = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/get_item_details', {'recid': recid, 'ln': ln}, (book_title_from_MARC(recid))) if borrower_name: borrower_link = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/get_borrower_details', {'borrower_id': borrower_id, 'ln': ln}, (borrower_name)) else: borrower_link = str(borrower_id) out += """ """ % (CFG_SITE_URL, borrower_link, title_link, library_name, location, date_from, date_to, request_date, _("Delete"), request_id, CFG_SITE_URL, request_id, recid, borrower_id, _("Associate barcode")) out += """
%s %s %s %s %s %s %s %s
%s %s %s %s %s %s %s



""" % (CFG_SITE_URL, _("Printable format")) return out def tmpl_register_ill_book_request(self, infos, ln=CFG_SITE_LANG): """ @param infos: informations @type infos: list @param ln: language of the page """ _ = gettext_set_language(ln) out = self.tmpl_infobox(infos, ln) out += _MENU_ out += """


%s

Search item by any field barcode author title






""" % (CFG_SITE_URL, _("Check if the book already exists on CDS Invenio,"\ + " before to send your ILL request."), _("Back"), _("Search")) return out def tmpl_register_ill_book_request_result(self, result, ln=CFG_SITE_LANG): """ @param result: book's information @type result: list @param ln: language of the page """ _ = gettext_set_language(ln) out = _MENU_ if len(result) == 0: out += """

%s

""" % (_("0 items found.")) else: out += """

%s item(s) found

""" % (CFG_SITE_URL,len(result), _("Title"), _("Author"), _("Publisher"), _("No. Copies")) for recid in result: (book_author, book_editor, book_copies) = get_item_info_for_search_result(recid) title_link = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/get_item_details', {'recid': recid, 'ln': ln}, (book_title_from_MARC(recid))) out += """ """ % (title_link, book_author, book_editor, book_copies) out += """
%s %s %s %s
%s %s %s %s




""" % (_("Back"), _("Proceed anyway")) return out def tmpl_register_ill_book_request_from_borrower_page(self, infos, borrower_id, ln=CFG_SITE_LANG): """ @param infos: informations @type infos: list @param borrower_id: identify the borrower. Primary key of crcBORROWER. @type borrower_id: int @param ln: language of the page """ _ = gettext_set_language(ln) out = self.tmpl_infobox(infos, ln) out += _MENU_ out += """


%s

Search item by any field barcode author title






""" % (CFG_SITE_URL, borrower_id, _("Check if the book already exists on CDS Invenio,"\ " before to send your ILL request."), _("Back"), _("Search")) return out def tmpl_register_ill_book_request_from_borrower_page_result(self, result, ln=CFG_SITE_LANG): """ @param result: book's information @type result: list @param borrower_id: identify the borrower. Primary key of crcBORROWER. @type borrower_id: int @param ln: language of the page """ _ = gettext_set_language(ln) out = """ """ out += _MENU_ if len(result) == 0: out += """

%s

""" % (_("0 items found.")) else: out += """

%s item(s) found

""" % (len(result), _("Title"), _("Author"), _("Publisher"), _("No. Copies")) for recid in result: (book_author, book_editor, book_copies) = get_item_info_for_search_result(recid) title_link = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/get_item_details', {'recid': recid, 'ln': ln}, (book_title_from_MARC(recid))) out += """ """ % (title_link, book_author, book_editor, book_copies) out += """
%s %s %s %s
%s %s %s %s




""" % (_("Back")) return out def tmpl_register_ill_request_from_borrower_page_step1(self, infos, borrower_id, ln=CFG_SITE_LANG): """ @param infos: informations @type infos: list @param borrower_id: identify the borrower. Primary key of crcBORROWER. @type borrower_id: int """ _ = gettext_set_language(ln) out = self.tmpl_infobox(infos, ln) out += _MENU_ out += """

%s


%s
%s
%s
%s
%s
%s
%s
%s

""" % (_("Book does not exists on CDS Invenio. Please fill the following form."), CFG_SITE_URL, borrower_id, _("Item details"), _("Book title"), _("Author(s)"), _("Place"), _("Publisher"), _("Year"), _("Edition"), _("ISBN")) conditions_link = """conditions""" out += """
%s
%s select period of interest
%s select period of interest
%s
%s



""" % (_("ILL request details"), _("Period of interest - From"), _("period_of_interest_from"), _("jsCal1"), _("period_of_interest_from"), _("jsCal1"), _("Period of interest - To"), _("period_of_interest_to"), _("jsCal2"), _("period_of_interest_to"), _("jsCal2"), _("Additional comments"), _("Borrower accepts the %s of the service in particular the return of books in due time." % (conditions_link)), _("Borrower wants this edition only."), _("Back"), _("Continue")) return out def tmpl_register_ill_request_from_borrower_page_step3(self, book_info, user_info, request_details, ln): """ @param book_info: book's informations @type book_info: tuple @param user_info: user's informations @type user_info: tuple @param request_details: details about a given request @type request_details: tuple """ _ = gettext_set_language(ln) (title, authors, place, publisher, year, edition, isbn) = book_info (borrower_id, ccid, name, email, phone, address, mailbox) = user_info display_id = borrower_id id_string= _("ID") if CFG_CERN_SITE == 1: display_id=ccid id_string= _("CCID") (period_of_interest_from, period_of_interest_to, additional_comments, only_edition)= request_details out = """ """ out += _MENU_ out += """


%s
%s %s
%s %s
%s %s
%s %s
%s %s
%s %s
%s %s
%s
%s %s
%s %s
%s %s
%s %s
%s
%s %s
%s %s
%s %s
%s %s
%s %s
%s %s
""" % (CFG_SITE_URL, _("Item details"), book_info, _("Title"), title, _("Author(s)"), authors, _("Place"), place, _("Year"), year, _("Publisher"), publisher, _("Edition"), edition, _("ISBN"), isbn, _("ILL request details"), request_details, _("Period of interest - From"), period_of_interest_from, _("Period of interest - To"), period_of_interest_to, _("Additional comments"), additional_comments, _("Only this edition"), only_edition or 'No', _("Borrower details"), user_info, id_string, display_id, _("Name"), name, _("Email"), email, _("Phone"), phone, _("Address"), address, _("Mailbox"), mailbox) out += """
""" % (_("Back"), _("Continue")) return out def tmpl_register_ill_article_request_step1(self, infos, ln=CFG_SITE_LANG): """ @param infos: informations @type infos: list """ _ = gettext_set_language(ln) out = self.tmpl_infobox(infos, ln) out += _MENU_ out += """



%s
%s
%s
%s
%s
%s
%s
%s
%s
%s
%s

""" % (CFG_SITE_URL, _("Article details"), _("Periodical title"), _("Article title"), _("Author(s)"), _("Report number"), _("Volume"), _("Issue"), _("Page"), _("Year"), _("Budget code"), _("ISSN")) #conditions_link = """conditions""" out += """
%s
%s
%s
%s



""" % (CFG_SITE_URL,CFG_SITE_URL,_("ILL request details"), _("Period of interest - From"), CFG_SITE_URL, datetime.date.today().strftime('%Y-%m-%d'), _("Period of interest - To"), CFG_SITE_URL, (datetime.date.today() + datetime.timedelta(days=365)).strftime('%Y-%m-%d'), _("Additional comments"), _("Back"), _("Continue")) return out def tmpl_register_ill_article_request_step2(self, article_info, request_details, result, key, string, infos, ln): """ @param article_info: information about article @type article_info: tuple @param request_details: details about a given ILL request @type request_details: tuple @param result: result with borrower's information @param result: list @param key: field (name, email, etc...) @param key: string @param string: pattern @type string: string @param infos: informations @type infos: list """ (periodical_title, article_title, author, report_number, volume, issue, page, year, issn) = article_info (period_of_interest_from, period_of_interest_to, additional_comments)= request_details _ = gettext_set_language(ln) out = self.tmpl_infobox(infos, ln) out += _MENU_ out += """

%s
""" % (CFG_SITE_URL, _("Item details"), _("Periodical title"), periodical_title, periodical_title, _("Article title"), article_title, article_title, _("Author(s)"), author, author, _("Report number"), report_number, report_number, _("Volume"), volume, volume, _("Issue"), issue, issue, _("Page"), page, page, _("Year"), year, year, _("ISSN"), issn, issn, _("ILL request details"), _("Period of interest - From"), period_of_interest_from, period_of_interest_from, _("Period of interest - To"), period_of_interest_to, period_of_interest_to, _("Additional comments"), additional_comments, additional_comments) out += """
%s %s
%s %s
%s %s
%s %s
%s %s
%s %s
%s %s
%s %s
%s %s
%s
%s %s
%s %s
%s %s
""" if CFG_CERN_SITE == 1: out += """
Search user by """ if key == 'email': out += """ ccid name email """ elif key == 'name': out += """ ccid name email """ else: out += """ ccid name email """ else: out += """
Search borrower by """ if key == 'email': out += """ id name email """ elif key == 'id': out += """ id name email """ else: out += """ id name email """ out += """


""" % (string or '') if result: out += """
""" % (_("Select user"), request_details) out += """




""" return out def tmpl_ill_search(self, infos, ln=CFG_SITE_LANG): """ Display form for ILL search @param infos: informations @type infos: list @param ln: language of the page """ _ = gettext_set_language(ln) out = self.tmpl_infobox(infos, ln) out += _MENU_ # # out += """



Search ILL request by title ill_request_id

""" % (CFG_SITE_URL,CFG_SITE_URL,CFG_SITE_URL,CFG_SITE_URL) out += """
date restriction: From
To
""" % (CFG_SITE_URL,_("the beginning"),CFG_SITE_URL,_("now")) out += """




""" % (_("Back"), _("Search")) return out def tmpl_delete_copy_step1(self, barcode_to_delete, recid, result, infos, ln=CFG_SITE_LANG): """ @param ln: language of the page """ _ = gettext_set_language(ln) #out = self.tmpl_infobox(infos, ln) out = _MENU_ (book_title, book_year, book_author, book_isbn, book_editor) = book_information_from_MARC(int(recid)) if book_isbn: book_cover = get_book_cover(book_isbn) else: book_cover = "%s/img/book_cover_placeholder.gif" % (CFG_SITE_URL) out += """

%s
%s %s
%s %s
%s %s
%s %s
%s %s
Book Cover

%s
""" % (CFG_SITE_URL, _("Item details"), _("Name"), book_title, _("Author(s)"), book_author, _("Year"), book_year, _("Publisher"), book_editor, _("ISBN"), book_isbn, str(book_cover), _("Copies of %s" % book_title)) out += """""" % (_("Barcode"), _("Status"), _("Due date"), _("Library"), _("Location"), _("Loan period"), _("No of loans"), _("Collection"), _("Description")) for (barcode, loan_period, lib_name, libid, location, nb_requests, status, collection, description, due_date) in result: library_link = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/get_library_details', {'library_id': libid, 'ln': ln}, (lib_name)) out += """ """ % (barcode, status, due_date, library_link, location, loan_period, nb_requests, collection or '-', description or '-') out += """
%s %s %s %s %s %s %s %s %s
%s %s %s %s %s %s %s %s %s
""" out += self.tmpl_infobox(infos, ln) out += """""" % (_("Barcode"), _("Status"), _("Due date"), _("Library"), _("Location"), _("Loan period"), _("No of loans"), _("Collection"), _("Description")) for (barcode, loan_period, lib_name, libid, location, nb_requests, status, collection, description, due_date) in result: if barcode == barcode_to_delete: library_link = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/get_library_details', {'library_id': libid, 'ln': ln}, (lib_name)) out += """ """ % (barcode, status, due_date, library_link, location, loan_period, nb_requests, collection or '-', description or '-') out += """
%s %s %s %s %s %s %s %s %s
%s %s %s %s %s %s %s %s %s
""" out+= """""" % (str(barcode_to_delete)) out+= """"""%(_("Back")) out+= """""" %(_("Delete")) out += """
""" return out \ No newline at end of file diff --git a/modules/bibcirculation/lib/bibcirculationadminlib.py b/modules/bibcirculation/lib/bibcirculationadminlib.py index 308576559..aa2881d36 100644 --- a/modules/bibcirculation/lib/bibcirculationadminlib.py +++ b/modules/bibcirculation/lib/bibcirculationadminlib.py @@ -1,6139 +1,6139 @@ # Administrator interface for Bibcirculation ## ## This file is part of CDS Invenio. ## Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 CERN. ## ## CDS Invenio is free software; you can redistribute it and/or ## modify it under the terms of the GNU General Public License as ## published by the Free Software Foundation; either version 2 of the ## License, or (at your option) any later version. ## ## CDS Invenio is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with CDS Invenio; if not, write to the Free Software Foundation, Inc., ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. from __future__ import division """CDS Invenio Bibcirculation Administrator Interface.""" __revision__ = "$Id$" __lastupdated__ = """$Date$""" import datetime, time # Others Invenio imports from invenio.config import \ CFG_SITE_LANG, \ CFG_SITE_URL, \ CFG_CERN_SITE import invenio.access_control_engine as acce from invenio.webpage import page from invenio.webuser import getUid, page_not_authorized from invenio.mailutils import send_email from invenio.search_engine import perform_request_search from invenio.urlutils import create_html_link, redirect_to_url from invenio.messages import gettext_set_language from invenio.bibcirculation_utils import book_title_from_MARC, \ update_status_if_expired, \ renew_loan_for_X_days, \ print_pending_hold_requests_information, \ print_new_loan_information, \ update_request_data, \ validate_date_format, \ create_ill_record, \ generate_email_body, \ book_information_from_MARC,\ search_user #get_list_of_ILL_requests, \ #create_item_details_url # Bibcirculation imports from invenio.bibcirculation_config import \ CFG_BIBCIRCULATION_TEMPLATES, CFG_BIBCIRCULATION_AMAZON_ACCESS_KEY, \ - CFG_BIBCIRCULATION_LIBRARIAN_EMAIL + CFG_BIBCIRCULATION_LIBRARIAN_EMAIL, CFG_BIBCIRCULATION_LOANS_EMAIL import invenio.bibcirculation_dblayer as db import invenio.template bibcirculation_templates = invenio.template.load('bibcirculation') def is_adminuser(req): """check if user is a registered administrator. """ return acce.acc_authorize_action(req, "runbibcirculation") def mustloginpage(req, message): """show a page asking the user to login.""" navtrail_previous_links = '' \ 'Admin Area > ' \ '' \ 'BibCirculation Admin ' % (CFG_SITE_URL, CFG_SITE_URL) return page_not_authorized(req=req, text=message, navtrail=navtrail_previous_links) def index(req, ln=CFG_SITE_LANG): """main function to show pages for bibcirculationadmin """ navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_index(ln=ln) return page(title="BibCirculation Admin", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def item_search_result(req, p, f, ln=CFG_SITE_LANG): """ Search an item and return a list with all the possible results. To retrieve the information desired, we use the method 'perform_request_search' (from search_engine.py). In the case of BibCirculation, we are just looking for books (items) inside the collection 'Books'. @type p: string @param p: search pattern @type f: string @param f: search field @return: list of recids """ if p == '': infos = [] infos.append('Empty string. Please, try again.') return item_search(req, infos, ln) if f == 'barcode': has_recid = db.get_recid(p) infos = [] if has_recid is None: infos.append('The barcode %s does not exist on BibCirculation database.' % p) body = bibcirculation_templates.tmpl_item_search(infos=infos, ln=ln) else: body = bibcirculation_templates.tmpl_item_search_result(result=has_recid, ln=ln) else: result = perform_request_search(cc="Books", sc="1", p=p, f=f) body = bibcirculation_templates.tmpl_item_search_result(result=result, ln=ln) navtrail_previous_links = 'Admin Area' \ ' > Circulation Management' \ ' ' % (CFG_SITE_URL, CFG_SITE_URL) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) return page(title="Item search result", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def borrower_search(req, empty_barcode, redirect='no', ln=CFG_SITE_LANG): """ Page (for administrator) where is it possible to search for a borrower (who is on crcBORROWER table) using his/her name, email, phone or id. """ infos = [] if empty_barcode: infos.append(empty_barcode) navtrail_previous_links = 'Admin Area' \ ' > Circulation Management' \ ' ' % (CFG_SITE_URL, CFG_SITE_URL) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_borrower_search(infos=infos, redirect=redirect, ln=ln) if redirect == 'yes': title="New Request" else: title="Borrower Search" return page(title=title, uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def borrower_search_result(req, column, string, redirect='no', ln=CFG_SITE_LANG): """ Search a borrower and return a list with all the possible results. @type column: string @param column: identify the column, of the table crcBORROWER, who will be considered during the search. Can be 'name', 'email' or 'id'. @type string: string @param string: string used for the search process. @return: list of borrowers. """ if string == '': message = 'Empty string. Please, try again.' return borrower_search(req, message, redirect, ln) else: result = search_user(column, string) navtrail_previous_links = 'Admin Area' \ ' > Circulation Management' \ ' ' % (CFG_SITE_URL, CFG_SITE_URL) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) if len(result) == 1: if redirect=='no': return get_borrower_details(req, result[0][0], ln) else: return create_new_request_step1(req, result[0][0]) else: body = bibcirculation_templates.tmpl_borrower_search_result(result=result, redirect=redirect, ln=ln) return page(title="Borrower search result", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def item_search(req, infos=[], ln=CFG_SITE_LANG): """ Display a form where is possible to searh for an item. """ navtrail_previous_links = 'Admin Area' \ ' > Circulation Management' \ ' ' % (CFG_SITE_URL, CFG_SITE_URL) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) #infos = [] body = bibcirculation_templates.tmpl_item_search(infos=infos, ln=ln) return page(title="Item search", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def load_template(template): """ Load a letter/notification template from bibcirculation_config.py. @type template: string. @param template: template who will be used in the notification. @return: template(string) """ if template == "overdue_letter": output = CFG_BIBCIRCULATION_TEMPLATES['OVERDUE'] elif template == "reminder": output = CFG_BIBCIRCULATION_TEMPLATES['REMINDER'] elif template == "notification": output = CFG_BIBCIRCULATION_TEMPLATES['NOTIFICATION'] elif template == "claim_return": output = CFG_BIBCIRCULATION_TEMPLATES['SEND_RECALL'] else: output = CFG_BIBCIRCULATION_TEMPLATES['EMPTY'] return output def borrower_notification(req, borrower_id, borrower_email, template, message, load_msg_template, subject, send_message, ln=CFG_SITE_LANG): """ Send a message/email to a borrower. @type borrower_id: integer. @param borrower_id: identify the borrower. It is also the primary key of the table crcBORROWER. @type template: string. @param template: identify the template who will be used in the notification. @type message: string. @param message: message written by the administrator. @type subject: string. @param subject: subject of the message. @return: send a message/email to a borrower. """ if borrower_email != None: email = borrower_email else: email = db.get_borrower_email(borrower_id) if load_msg_template and template is not None: show_template = load_template(template) elif send_message: send_email(fromaddr = CFG_BIBCIRCULATION_LIBRARIAN_EMAIL, toaddr = email, subject = subject, content = message, header = '', footer = '', attempt_times=1, attempt_sleeptime=10 ) body = bibcirculation_templates.tmpl_send_notification(ln=ln) else: show_template = load_template(template) body = bibcirculation_templates.tmpl_borrower_notification(email=email, subject=subject, template=show_template, borrower_id=borrower_id, ln=ln) navtrail_previous_links = 'Admin Area' \ ' > Circulation Management' \ ' ' % (CFG_SITE_URL, CFG_SITE_URL) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) return page(title="Borrower Notification", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def get_next_waiting_loan_request(req, recid, barcode, check_id, ln=CFG_SITE_LANG): """ Return the next loan request who is waiting or pending. @type recid: integer. @param recid: identify the record. It is also the primary key of the table bibrec. @type barcode: string. @param barcode: identify the item. It is the primary key of the table crcITEM. @type check_id: integer. @param check_id: identify the hold request. It is also the primary key of the table crcLOANREQUEST. @return: list of waiting requests with the same recid. """ if check_id: db.update_loan_request_status(check_id,'cancelled') update_request_data(check_id) else: returned_on = datetime.date.today() db.update_item_status('available', barcode) db.update_loan_info(returned_on, 'returned', barcode) result = db.get_next_waiting_loan_request(recid) navtrail_previous_links = 'Admin Area' \ ' > Circulation Management' \ ' ' % (CFG_SITE_URL, CFG_SITE_URL) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_get_next_waiting_loan_request(result=result, recid=recid, barcode=barcode, ln=ln) return page(title="Next requests", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def update_next_loan_request_status(req, check_id, barcode, ln=CFG_SITE_LANG): """ Update the status of a loan request who is defined as 'waiting' or 'pending'. The new status can be 'done' or 'cancelled'. @type check_id: integer. @param check_id: identify the hold request. It is also the primary key of the table crcLOANREQUEST. @type barcode: string. @param barcode: identify the item. It is the primary key of the table crcITEM. """ recid = db.get_request_recid(check_id) borrower_id = db.get_request_borrower_id(check_id) borrower_info = db.get_borrower_details(borrower_id) loaned_on = datetime.date.today() due_date = renew_loan_for_X_days(barcode) db.update_loan_request_status(check_id,'done') db.update_request_barcode(barcode, check_id) db.new_loan(borrower_id, recid, barcode, loaned_on, due_date, 'on loan', 'normal','') db.update_item_status('on loan', barcode) navtrail_previous_links = 'Admin Area' \ ' > Circulation Management' \ ' ' % (CFG_SITE_URL, CFG_SITE_URL) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_register_new_loan(borrower_info=borrower_info, recid=recid, ln=ln) return page(title="New Loan", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def loan_return(req, ln=CFG_SITE_LANG): """ Page where is possible to register the return of an item. """ infos = [] navtrail_previous_links = 'Admin Area' \ ' > Circulation Management' \ ' ' % (CFG_SITE_URL, CFG_SITE_URL) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_loan_return(infos=infos, ln=ln) return page(title="Loan return", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def loan_on_desk_step1(req, key, string, ln=CFG_SITE_LANG): """ Step 1 of loan procedure. Search a user/borrower and return a list with all the possible results. @type key: string. @param key: attribute who will be considered during the search. Can be 'name', 'email' or 'ccid/id'. @type string: string. @param string: keyword used during the search. @return: list of potential borrowers. """ infos = [] if key and not string: infos.append('Empty string. Please, try again.') body = bibcirculation_templates.tmpl_loan_on_desk_step1(result=None, key=key, string=string, infos=infos, ln=ln) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) return page(title="Loan on desk", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) list_infos = [] if CFG_CERN_SITE == 1: if key =='ccid' and string: from invenio.bibcirculation_cern_ldap import get_user_info_from_ldap result = get_user_info_from_ldap(ccid=string) if result == 'busy': infos.append(bibcirculation_templates.tmpl_message_sever_busy(ln)) elif result: try: name = result['cn'][0] except KeyError: name = "" try: email = result['mail'][0] except KeyError: email = "" try: phone = result['telephoneNumber'][0] except KeyError: phone = "" try: address = result['physicalDeliveryOfficeName'][0] except KeyError: address = "" try: mailbox = result['postOfficeBox'][0] except KeyError: mailbox = "" try: ccid = result['employeeID'][0] except KeyError: ccid = "" tup = ('', ccid, name, email, phone, address, mailbox) list_infos.append(tup) elif key =='name' and string: result = db.get_borrower_data_by_name(string) for (borrower_id, ccid, name, email, phone, address, mailbox) in result: tup = (borrower_id, ccid, name, email, phone, address, mailbox) list_infos.append(tup) elif key =='email' and string: result = db.get_borrower_data_by_email(string) for (borrower_id, ccid, name, email, phone, address, mailbox) in result: tup = (borrower_id, ccid, name, email, phone, address, mailbox) list_infos.append(tup) else: result = list_infos else: if key =='name' and string: result = db.get_borrower_data_by_name(string) elif key =='email' and string: result = db.get_borrower_data_by_email(string) else: result = db.get_borrower_data_by_id(string) for (borrower_id, ccid, name, email, phone, address, mailbox) in result: tup = (borrower_id, ccid, name, email, phone, address, mailbox) list_infos.append(tup) if len(result) == 0 and key: infos.append("0 borrowers found. Search by CCID") elif len(list_infos) == 1: return loan_on_desk_step2(req, tup, ln) body = bibcirculation_templates.tmpl_loan_on_desk_step1(result=list_infos, key=key, string=string, infos=infos, ln=ln) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) return page(title="Circulation management", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def loan_on_desk_step2(req, user_info, ln=CFG_SITE_LANG): """ Display the user/borrower's information. @type ccid: integer. @type name: string. @type email: string. @type phone: string. @type address: string. @type mailbox: string. """ infos = [] body = bibcirculation_templates.tmpl_loan_on_desk_step2(user_info=user_info, infos=infos, ln=ln) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) return page(title="Circulation management", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def loan_on_desk_step3(req, user_info, barcode, ln=CFG_SITE_LANG): """ Display the user/borrower's information and associate a list of barcodes to him. @type user_info: list. @param user_info: information of the user/borrower who was selected. @type barcode: string. @param barcode: identify the item. It is the primary key of the table crcITEM. """ infos = [] list_of_books = [] list_of_barcodes = barcode.split() #user_info = [ccid, name, email, phone, address, mailbox] for value in list_of_barcodes: recid = db.get_id_bibrec(value) loan_id = db.is_item_on_loan(value) queue = db.get_queue_request(recid) if recid is None: infos.append('"%s" > Unknown barcode. Please, try again.' % value) body = bibcirculation_templates.tmpl_loan_on_desk_step2(user_info=user_info, infos=infos, ln=ln) elif loan_id: infos.append('The item with the barcode "%s" is on loan.' % value) body = bibcirculation_templates.tmpl_loan_on_desk_step2(user_info=user_info, infos=infos, ln=ln) else: (library_id, location) = db.get_lib_location(value) tup = (recid, value, library_id, location) list_of_books.append(tup) if len(queue) != 0: infos.append("Another user is waiting for the book: " \ + book_title_from_MARC(recid) +" ["+ value +"]. " \ "\n\n If you want continue with this loan choose" \ " [Continue].") body = bibcirculation_templates.tmpl_loan_on_desk_step3(user_info=user_info, list_of_books=list_of_books, infos=infos, ln=ln) if list_of_barcodes == []: infos.append('Empty barcode. Please, try again.') body = bibcirculation_templates.tmpl_loan_on_desk_step2(user_info=user_info, infos=infos, ln=ln) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) return page(title="Circulation management", uid=id_user, req=req, body=body, metaheaderadd = "" % CFG_SITE_URL, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def loan_on_desk_step4(req, list_of_books, user_info, due_date, note, ln=CFG_SITE_LANG): """ Register a new loan. @type list_of_books: list. @param list_of_books: list of books who will on loan. @type user_info: list. @param user_info: information of the user/borrower who was selected. @type due_date: list. @param due_date: list of due dates. @type note: string. @param note: note about the new loan. @return: new loan. """ id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) infos = [] (id, ccid, name, email, phone, address, mailbox) = user_info loaned_on = datetime.date.today() is_borrower = db.is_borrower(email) #Check if one of the given items is on loan. on_loan = [] for i in range(len(list_of_books)): is_on_loan = db.is_on_loan(list_of_books[i][1]) if is_on_loan: on_loan.append(list_of_books[i][1]) if len(on_loan) != 0: infos.append("The item(s) with barcode(s) %s is(are) already on loan." % on_loan) body = bibcirculation_templates.tmpl_loan_on_desk_step1(result=None, key='', string='', infos=infos, ln=ln) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) return page(title="Loan on desk", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) # validate the period of interest given by the admin for date in due_date: if validate_date_format(date) is False: infos = [] infos.append("The given due date %s" \ " is not a valid date or date format" % date) body = bibcirculation_templates.tmpl_loan_on_desk_step3(user_info=user_info, list_of_books=list_of_books, infos=infos, ln=ln) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) return page(title="Circulation management", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) if is_borrower == 0: db.new_borrower(ccid, name, email, phone, address, mailbox, '') is_borrower = db.is_borrower(email) for i in range(len(list_of_books)): note_format = {} if note: note_format[time.strftime("%Y-%m-%d %H:%M:%S")] = str(note) db.new_loan(is_borrower, list_of_books[i][0], list_of_books[i][1], loaned_on, due_date[i], 'on loan', 'normal', note_format) db.update_item_status('on loan', list_of_books[i][1]) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) return redirect_to_url(req, '%s/admin2/bibcirculation/all_loans?msg=ok' % CFG_SITE_URL) def loan_on_desk_confirm(req, barcode=None, borrower_id=None, ln=CFG_SITE_LANG): """ Confirm the return of an item. @type barcode: string. @param barcode: identify the item. It is the primary key of the table crcITEM. @type borrower_id: integer. @param borrower_id: identify the borrower. It is also the primary key of the table crcBORROWER. """ result = db.loan_on_desk_confirm(barcode, borrower_id) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_loan_on_desk_confirm(result=result, barcode=barcode, borrower_id=borrower_id, ln=ln) return page(title="Loan on desk confirm", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def register_new_loan(req, barcode, borrower_id, request_id, new_note, print_data, ln=CFG_SITE_LANG): """ Register a new loan. @type barcode: string. @param barcode: identify the item. It is the primary key of the table crcITEM. @type borrower_id: integer. @param borrower_id: identify the borrower. It is also the primary key of the table crcBORROWER. @type request_id: integer. @param request_id: identify the hold request. It is also the primary key of the table crcLOANREQUEST. @type new_note: string. @param new_note: associate a note to this loan. @type print_data: string. @param print_data: print the information about this loan. @return: new loan. """ _ = gettext_set_language(ln) has_recid = db.get_id_bibrec(barcode) loan_id = db.is_item_on_loan(barcode) recid = db.get_request_recid(request_id) list_of_barcodes = db.get_barcodes(recid) infos = [] if print_data == 'true': return print_new_loan_information(req, ln) if has_recid is None: infos.append('"%s" > Unknown barcode. Please try again.' % barcode) borrower = db.get_borrower_details(borrower_id) title="Associate barcode" body = bibcirculation_templates.tmpl_associate_barcode(request_id=request_id, recid=recid, borrower=borrower, infos=infos, ln=ln) elif loan_id: infos.append('The item with the barcode "%s" is on loan.' % barcode) borrower = db.get_borrower_details(borrower_id) title="Associate barcode" body = bibcirculation_templates.tmpl_associate_barcode(request_id=request_id, recid=recid, borrower=borrower, infos=infos, ln=ln) elif barcode not in list_of_barcodes: infos.append('The given barcode "%s" does not correspond to requested item.' % barcode) borrower = db.get_borrower_details(borrower_id) title="Associate barcode" body = bibcirculation_templates.tmpl_associate_barcode(request_id=request_id, recid=recid, borrower=borrower, infos=infos, ln=ln) else: recid = db.get_id_bibrec(barcode) loaned_on = datetime.date.today() due_date = renew_loan_for_X_days(barcode) if new_note: note_format = '[' + time.ctime() + '] ' + new_note + '\n' else: note_format = '' db.new_loan(borrower_id, recid, barcode, loaned_on, due_date, 'on loan', 'normal', note_format) requested_barcode = db.get_requested_barcode(request_id) if requested_barcode == barcode: db.update_item_status('on loan', barcode) else: db.update_item_status('on loan', barcode) db.update_item_status('available', requested_barcode) db.update_loan_request_status(request_id, 'done') db.update_request_barcode(barcode, request_id) #borrower_info = db.get_borrower_data(borrower_id) result = db.get_all_loans(20) infos.append('A new loan has been registered with success.') title="Current loans" body = bibcirculation_templates.tmpl_all_loans(result=result, infos=infos, ln=ln) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) return page(title=title, uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def loan_return_confirm(req, barcode, ln=CFG_SITE_LANG): """ Display a form where it is possible to register the return of an item. @type barcode: string. @param barcode: identify the item. It is the primary key of the table crcITEM. """ infos = [] recid = db.get_id_bibrec(barcode) loan_id = db.is_item_on_loan(barcode) if recid is None: infos.append('"%s" > Unknown barcode. Please try again.' % barcode) body = bibcirculation_templates.tmpl_loan_return(infos=infos, ln=ln) elif loan_id is None: infos.append('The item with the barcode %s is not on loan. Please try again.' % barcode) body = bibcirculation_templates.tmpl_loan_return(infos=infos, ln=ln) else: borrower_id = db.get_borrower_id(barcode) borrower_name = db.get_borrower_name(borrower_id) db.update_item_status('available', barcode) db.update_loan_info(datetime.date.today(), 'returned', barcode) result = db.get_next_waiting_loan_request(recid) body = bibcirculation_templates.tmpl_loan_return_confirm(borrower_name=borrower_name, borrower_id=borrower_id, recid=recid, barcode=barcode, return_date=datetime.date.today(), result=result, ln=ln) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) return page(title="Loan return", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def get_borrower_details(req, borrower_id, ln=CFG_SITE_LANG): """ Display the details of a borrower. @type borrower_id: integer. @param borrower_id: identify the borrower. It is also the primary key of the table crcBORROWER. """ borrower = db.get_borrower_details(borrower_id) if borrower == None: info = 'Borrower not found, please try again.' return borrower_search(req, info, 'no', ln) else: requests = db.get_borrower_request_details(borrower_id) loans = db.get_borrower_loan_details(borrower_id) notes = db.get_borrower_notes(borrower_id) ill = db.get_ill_requests_details(borrower_id) req_hist = db.bor_requests_historical_overview(borrower_id) loans_hist = db.bor_loans_historical_overview(borrower_id) ill_hist = db.bor_ill_historical_overview(borrower_id) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_borrower_details(borrower=borrower, requests=requests, loans=loans, notes=notes, ill=ill, req_hist=req_hist, loans_hist=loans_hist, ill_hist=ill_hist, ln=ln) return page(title="Borrower details", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def get_borrower_loans_details(req, recid, barcode, borrower_id, renewall, force, loan_id, ln=CFG_SITE_LANG): """ Show borrower's loans details. @type recid: integer. @param recid: identify the record. It is also the primary key of the table bibrec. @type barcode: string. @param barcode: identify the item. It is the primary key of the table crcITEM. @type borrower_id: integer. @param borrower_id: identify the borrower. It is also the primary key of the table crcBORROWER. @type renewall: string. @param renewall: renew all loans. @type force: string. @param force: force the renew of a loan, when usually this is not possible. @type loan_id: integer. @param loan_id: identify a loan. It is the primery key of the table crcLOAN. @return: borrower loans details. """ infos = [] force_renew_link = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/get_borrower_loans_details', {'barcode': barcode, 'borrower_id': borrower_id, 'loan_id': loan_id, 'force': 'true'}, ("Yes")) no_renew_link = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/get_borrower_loans_details', {'borrower_id': borrower_id}, ("No")) if barcode and loan_id and recid: queue = db.get_queue_request(recid) new_due_date = renew_loan_for_X_days(barcode) if len(queue) != 0: infos.append("Another user is waiting for this book "+ book_title_from_MARC(recid) +"." \ " \n\n Do you want renew this loan anyway? " \ " \n\n [%s] [%s]" % (force_renew_link, no_renew_link)) else: db.update_due_date(loan_id, new_due_date) update_status_if_expired(loan_id) infos.append("Loan renewed with success!") elif loan_id and barcode and force == 'true': new_due_date = renew_loan_for_X_days(barcode) db.update_due_date(loan_id, new_due_date) update_status_if_expired(loan_id) infos.append("Loan renewed with success.") elif borrower_id and renewall=='true': list_of_loans = db.get_recid_borrower_loans(borrower_id) for (loan_id, recid, barcode) in list_of_loans: queue = db.get_queue_request(recid) new_due_date = renew_loan_for_X_days(barcode) force_renewall_link = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/get_borrower_loans_details', {'barcode': barcode, 'borrower_id': borrower_id, 'loan_id': loan_id, 'force': 'true'}, ("Yes")) if len(queue) != 0: infos.append("Another user is waiting for this book "+ book_title_from_MARC(recid) +". " \ "\n\n Do you want renew this loan anyway? " \ "\n\n [%s] [%s]" % (force_renewall_link, no_renew_link)) else: db.update_due_date(loan_id, new_due_date) update_status_if_expired(loan_id) infos.append("All loans renewed with success.") borrower_loans = db.get_borrower_loan_details(borrower_id) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_borrower_loans_details(borrower_loans=borrower_loans, borrower_id=borrower_id, infos=infos, ln=ln) return page(title="Loans details - %s" % (db.get_borrower_name(borrower_id)), uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def get_item_loans_details(req, recid, barcode, loan_id, force, ln=CFG_SITE_LANG): """ Show all the details about all loans related with an item. @type recid: integer. @param recid: identify the record. It is also the primary key of the table bibrec. @type barcode: string. @param barcode: identify the item. It is the primary key of the table crcITEM. @type loan_id: integer. @param loan_id: identify a loan. It is the primery key of the table crcLOAN. @type force: string. @param force: force the renew of a loan, when usually this is not possible. @return: item loans details. """ infos = [] if loan_id and barcode and force == 'true': new_due_date = renew_loan_for_X_days(barcode) db.update_due_date(loan_id, new_due_date) infos.append("Loan renewed with success.") elif barcode: recid = db.get_id_bibrec(barcode) queue = db.get_queue_request(recid) new_due_date = renew_loan_for_X_days(barcode) force_renew_link = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/get_item_loans_details', {'barcode': barcode, 'loan_id': loan_id, 'force': 'true', 'recid': recid}, ("Yes")) no_renew_link = create_html_link(CFG_SITE_URL + '/admin2/bibcirculation/get_item_loans_details', {'recid': recid}, ("No")) if len(queue) != 0: infos.append("Another user is waiting for this book " \ "("+ book_title_from_MARC(recid) +"). \n\n Do you want renew " \ "this loan anyway? \n\n" \ " [%s] [%s]" % (force_renew_link, no_renew_link)) else: db.update_due_date(loan_id, new_due_date) infos.append("Loan renewed with success.") result = db.get_item_loans(recid) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_get_item_loans_details(result=result, recid=recid, infos=infos, ln=ln) return page(title="Loans details - %s" % (book_title_from_MARC(int(recid))), uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def get_item_details(req, recid, ln=CFG_SITE_LANG): """ Display the details of an item. @type recid: integer. @param recid: identify the record. It is also the primary key of the table bibrec. @return: item details. """ infos = [] copies = db.get_item_copies_details(recid) requests = db.get_item_requests(recid) loans = db.get_item_loans(recid) req_hist_overview = db.get_item_requests_historical_overview(recid) loans_hist_overview = db.get_item_loans_historical_overview(recid) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_get_item_details(recid=recid, copies=copies, requests=requests, loans=loans, req_hist_overview = req_hist_overview, loans_hist_overview = loans_hist_overview, infos=infos, ln=ln) return page(title="Item details", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def get_item_req_historical_overview(req, recid, ln=CFG_SITE_LANG): """ Display the requests historical overview of an item. @type recid: integer. @param recid: identify the record. It is also the primary key of the table bibrec. @return: Item requests - historical overview. """ req_hist_overview = db.get_item_requests_historical_overview(recid) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_get_item_req_historical_overview(req_hist_overview = req_hist_overview, ln=ln) return page(title="Requests - historical overview", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def get_item_loans_historical_overview(req, recid, ln=CFG_SITE_LANG): """ Display the loans historical overview of an item. @type recid: integer. @param recid: identify the record. It is also the primary key of the table bibrec. @return: Item loans - historical overview. """ loans_hist_overview = db.get_item_loans_historical_overview(recid) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_get_item_loans_historical_overview(loans_hist_overview = loans_hist_overview, ln=ln) return page(title="Loans - historical overview", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def bor_loans_historical_overview(req, borrower_id, ln=CFG_SITE_LANG): """ Display the loans historical overview of a borrower. @type borrower_id: integer. @param borrower_id: identify the borrower. It is also the primary key of the table crcBORROWER. @return: borrower loans - historical overview. """ loans_hist_overview = db.bor_loans_historical_overview(borrower_id) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_bor_loans_historical_overview( loans_hist_overview = loans_hist_overview, ln=ln) return page(title="Loans - historical overview", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def bor_requests_historical_overview(req, borrower_id, ln=CFG_SITE_LANG): """ Display the requests historical overview of a borrower. @type borrower_id: integer. @param borrower_id: identify the borrower. It is also the primary key of the table crcBORROWER. @return: borrower requests - historical overview. """ req_hist_overview = db.bor_requests_historical_overview(borrower_id) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_bor_requests_historical_overview( req_hist_overview = req_hist_overview, ln=ln) return page(title="Requests - historical overview", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def get_library_details(req, library_id, ln=CFG_SITE_LANG): """ Display the details of a library. @type library_id: integer. @param library_id: identify the library. It is also the primary key of the table crcLIBRARY. @return: library details. """ library_details = db.get_library_details(library_id) library_items = db.get_library_items(library_id) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_library_details(library_details=library_details, library_items=library_items, ln=ln) return page(title="Library details", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def get_borrower_requests_details(req, borrower_id, request_id, ln=CFG_SITE_LANG): """ Display loans details of a borrower. @type borrower_id: integer. @param borrower_id: identify the borrower. It is also the primary key of the table crcBORROWER. @type request_id: integer. @param request_id: identify the hold request. It is also the primary key of the table crcLOANREQUEST. @return: borrower requests details. """ if request_id: db.cancel_request(request_id, 'cancelled') update_request_data(request_id) result = db.get_borrower_request_details(borrower_id) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) name = db.get_borrower_name(borrower_id) title = "Hold requests details - %s" % (name) body = bibcirculation_templates.tmpl_borrower_request_details(result=result, borrower_id=borrower_id, ln=ln) return page(title=title, uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def get_pending_requests(req, request_id, print_data, ln=CFG_SITE_LANG): """ Get all loans requests who are pending. @type request_id: integer. @param request_id: identify the hold request. It is also the primary key of the table crcLOANREQUEST. @type print_data: string. @param print_data: print requests information. @return: list of pending requests (on shelf with hold). """ _ = gettext_set_language(ln) if print_data == 'true': return print_pending_hold_requests_information(req, ln) elif request_id: db.update_loan_request_status(request_id,'cancelled') update_request_data(request_id) result = db.get_loan_request_by_status('pending') else: result = db.get_loan_request_by_status('pending') navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_get_pending_requests(result=result, ln=ln) return page(title="Items on shelf with holds", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def get_waiting_requests(req, request_id, print_data, ln=CFG_SITE_LANG): """ Get all loans requests who are waiting. @type request_id: integer. @param request_id: identify the hold request. It is also the primary key of the table crcLOANREQUEST. @type print_data: string. @param print_data: print requests information. @return: list of waiting requests (on loan with hold). """ _ = gettext_set_language(ln) if print_data == 'true': return print_pending_hold_requests_information(req, ln) elif request_id: db.update_loan_request_status(request_id,'cancelled') update_request_data(request_id) result = db.get_loan_request_by_status('waiting') else: result = db.get_loan_request_by_status('waiting') navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_get_waiting_requests(result=result, ln=ln) return page(title="Items on loan with holds", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def all_requests(req, request_id, ln=CFG_SITE_LANG): """ Display all requests. @type request_id: integer. @param request_id: identify the hold request. It is also the primary key of the table crcLOANREQUEST. """ if request_id: db.update_loan_request_status(request_id, "cancelled") update_request_data(request_id) result = db.get_all_requests() else: result = db.get_all_requests() navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_all_requests(result=result, ln=ln) return page(title="List of hold requests", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def all_loans(req, msg=None, ln=CFG_SITE_LANG): """ Display all loans. @type loans_per_page: integer. @param loans_per_page: number of loans per page. @type jloan: integer. @param jloan: jump to next loan. @return: list with all loans (current loans). """ infos = [] if msg=='ok': infos.append('A new loan has been registered with success.') result = db.get_all_loans(20) navtrail_previous_links = 'Admin Area' \ ' > Circulation Management' \ ' ' % (CFG_SITE_URL, CFG_SITE_URL) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_all_loans(result=result, infos=infos, ln=ln) return page(title="Current loans", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def all_loans_test(req, ln=CFG_SITE_LANG): """ Display all loans. @return: list with all loans (current loans). """ result = db.get_all_loans(20) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_all_loans_test(result=result, ln=ln) return page(title="TEST loans", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def all_expired_loans(req, ln=CFG_SITE_LANG): """ Display all loans. @type loans_per_page: integer. @param loans_per_page: number of loans per page. @type jloan: integer. @param jloan: jump to next loan. @return: list with all expired loans (overdue loans). """ result = db.get_all_expired_loans() infos = [] navtrail_previous_links = 'Admin Area' \ ' > Circulation Management' \ ' ' % (CFG_SITE_URL, CFG_SITE_URL) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_all_expired_loans(result=result, infos=infos, ln=ln) return page(title='Overdue loans', uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def get_item_requests_details(req, recid, request_id, ln=CFG_SITE_LANG): """ Display all requests for a specific item. @type recid: integer. @param recid: identify the record. It is also the primary key of the table bibrec. @type request_id: integer. @param request_id: identify the hold request. It is also the primary key of the table crcLOANREQUEST. @return: Item requests details. """ if request_id: db.cancel_request(request_id, 'cancelled') update_request_data(request_id) result = db.get_item_requests(recid) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_get_item_requests_details(recid=recid, result=result, ln=ln) return page(title="Hold requests - %s" % (book_title_from_MARC(recid)), uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def associate_barcode(req, request_id, recid, borrower_id, ln=CFG_SITE_LANG): """ Associate a barcode to an hold request. @type request_id: integer. @param request_id: identify the hold request. It is also the primary key of the table crcLOANREQUEST. @type recid: integer. @param recid: identify the record. It is also the primary key of the table bibrec. @type borrower_id: integer. @param borrower_id: identify the borrower. It is also the primary key of the table crcBORROWER. """ borrower = db.get_borrower_details(borrower_id) infos = [] navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_associate_barcode(request_id=request_id, recid=recid, borrower=borrower, infos=infos, ln=ln) return page(title="Associate barcode", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def get_borrower_notes(req, borrower_id, delete_key, library_notes, ln=CFG_SITE_LANG): """ Retrieve the notes of a borrower. @type borrower_id: integer. @param borrower_id: identify the borrower. It is also the primary key of the table crcBORROWER. """ id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) if delete_key and borrower_id: borrower_notes = eval(db.get_borrower_notes(borrower_id)) del borrower_notes[delete_key] db.update_borrower_notes(borrower_id, borrower_notes) elif library_notes: if db.get_borrower_notes(borrower_id): borrower_notes = eval(db.get_borrower_notes(borrower_id)) else: borrower_notes = {} borrower_notes[time.strftime("%Y-%m-%d %H:%M:%S")] = str(library_notes) db.update_borrower_notes(borrower_id, borrower_notes) borrower_notes = db.get_borrower_notes(borrower_id) navtrail_previous_links = 'Admin Area' \ ' > Circulation Management' \ ' ' % (CFG_SITE_URL, CFG_SITE_URL) body = bibcirculation_templates.tmpl_borrower_notes(borrower_notes=borrower_notes, borrower_id=borrower_id, ln=ln) return page(title="Borrower notes", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def get_loans_notes(req, loan_id, delete_key, library_notes, back, ln=CFG_SITE_LANG): """ Get loan's note(s). @type loan_id: integer. @param loan_id: identify a loan. It is the primery key of the table crcLOAN. """ if delete_key and loan_id: loans_notes = eval(db.get_loan_notes(loan_id)) del loans_notes[delete_key] db.update_loan_notes(loan_id, loans_notes) elif library_notes: if db.get_loan_notes(loan_id): loans_notes = eval(db.get_loan_notes(loan_id)) else: loans_notes = {} loans_notes[time.strftime("%Y-%m-%d %H:%M:%S")] = str(library_notes) db.update_loan_notes(loan_id, loans_notes) loans_notes = db.get_loan_notes(loan_id) navtrail_previous_links = 'Admin Area' \ ' > Circulation Management' \ ' ' % (CFG_SITE_URL, CFG_SITE_URL) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) referer = req.headers_in.get('referer') body = bibcirculation_templates.tmpl_get_loans_notes(loans_notes=loans_notes, loan_id=loan_id, referer=referer, back=back, ln=ln) return page(title="Loan notes", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def add_new_borrower_step1(req, ln=CFG_SITE_LANG): """ Add new borrower. Step 1 """ navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_add_new_borrower_step1(ln=ln) return page(title="Add new borrower - I", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def add_new_borrower_step2(req, name, email, phone, address, mailbox, notes, ln=CFG_SITE_LANG): """ Add new borrower. Step 2. @type name: string. @type email: string. @type phone: string. @type address: string. @type mailbox: string. @type notes: string. """ infos = [] is_borrower = db.is_borrower(email) if is_borrower != 0: infos.append("There is already a borrower using "\ "the following email: \n\n %s \n\n"\ "Please go back to previous page and give a different email. " % email) tup_infos = (name, email, phone, address, mailbox, notes) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_add_new_borrower_step2(tup_infos=tup_infos, infos=infos, ln=ln) return page(title="Add new borrower - II", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def add_new_borrower_step3(req, tup_infos, ln=CFG_SITE_LANG): """ Add new borrower. Step 3. @type tup_infos: tuple. @param tup_infos: tuple containing borrower information. """ db.new_borrower('', tup_infos[0], tup_infos[1], tup_infos[2], tup_infos[3], tup_infos[4], tup_infos[5]) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_add_new_borrower_step3(ln=ln) return page(title="Add new borrower - III", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def update_borrower_info_step1(req, ln=CFG_SITE_LANG): """ Update the borrower's information. """ navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_update_borrower_info_step1(ln=ln) return page(title="Update borrower information - I", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def update_borrower_info_step2(req, column, string, ln=CFG_SITE_LANG): """ Update the borrower's information. """ if column == 'name': result = db.search_borrower_by_name(string) elif column == 'phone': result = db.search_borrower_by_phone(string) elif column == 'email': result = db.search_borrower_by_email(string) else: result = db.search_borrower_by_id(string) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_update_borrower_info_step2(result=result, ln=ln) return page(title="Update borrower information - II", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def update_borrower_info_step3(req, borrower_id, ln=CFG_SITE_LANG): """ Update the borrower's information. @param borrower_id: identify the borrower. It is also the primary key of the table crcBORROWER. """ result = db.get_borrower_details(borrower_id) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_update_borrower_info_step3(result=result, ln=ln) return page(title="Update borrower information - III", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def update_borrower_info_step4(req, name, email, phone, address, mailbox, ln=CFG_SITE_LANG): """ Update the borrower's information. """ tup_infos = (name, email, phone, address, mailbox) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_update_borrower_info_step4(tup_infos=tup_infos, ln=ln) return page(title="Update borrower information - IV", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def update_borrower_info_step5(req, tup_infos, ln=CFG_SITE_LANG): """ Update the borrower's information. """ borrower_id = db.is_borrower(tup_infos[1]) db.update_borrower_info(borrower_id, tup_infos[0], tup_infos[1], tup_infos[2], tup_infos[3], tup_infos[4]) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_update_borrower_info_step5(ln=ln) return page(title="Update borrower information - V", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def get_item_loans_notes(req, loan_id, add_notes, new_note, ln=CFG_SITE_LANG): """ Get loan's notes. @param loan_id: identify a loan. It is the primery key of the table crcLOAN. @param recid: identify the record. It is also the primary key of the table bibrec. @param borrower_id: identify the borrower. It is also the primary key of the table crcBORROWER. @param add_notes: display the textarea where will be written a new notes. @param new_notes: note who will be added to the others library's notes. """ if new_note: date = '[' + time.ctime() + '] ' new_line = '\n' new_note = date + new_note + new_line db.add_new_loan_note(new_note, loan_id) loans_notes = db.get_loans_notes(loan_id) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_get_loans_notes(loans_notes=loans_notes, loan_id=loan_id, add_notes=add_notes, ln=ln) return page(title="Loan notes", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def new_item(req, isbn, ln=CFG_SITE_LANG): """ Add a new item using the ISBN. """ book_info = [] errors = [] navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) if isbn: from xml.dom import minidom import urllib filexml = urllib.urlopen('http://ecs.amazonaws.com/onca/xml?' \ 'Service=AWSECommerceService&AWSAccessKeyId=' \ + CFG_BIBCIRCULATION_AMAZON_ACCESS_KEY + \ '&Operation=ItemSearch&Condition=All&' \ 'ResponseGroup=ItemAttributes&SearchIndex=Books&' \ 'Keywords=' + isbn) xmldoc = minidom.parse(filexml) try: get_error_code = xmldoc.getElementsByTagName('Code') get_error_message = xmldoc.getElementsByTagName('Message') error_code = get_error_code.item(0).firstChild.data error_message = get_error_message.item(0).firstChild.data errors.append(str(error_code)) errors.append(str(error_message)) except AttributeError: errors = "" try: get_author = xmldoc.getElementsByTagName('Author') author = get_author.item(0).firstChild.data book_info.append(str(author)) except AttributeError: author = "" book_info.append(str(author)) try: get_ean = xmldoc.getElementsByTagName('EAN') ean = get_ean.item(0).firstChild.data book_info.append(int(ean)) except AttributeError: ean = "" book_info.append(str(ean)) try: get_isbn = xmldoc.getElementsByTagName('ISBN') short_isbn = get_isbn.item(0).firstChild.data book_info.append(str(short_isbn)) except AttributeError: short_isbn = "" book_info.append(str(short_isbn)) try: get_publisher = xmldoc.getElementsByTagName('Manufacturer') publisher = get_publisher.item(0).firstChild.data book_info.append(str(publisher)) except AttributeError: publisher = "" book_info.append(str(publisher)) try: get_nb_pages = xmldoc.getElementsByTagName('NumberOfPages') nb_pages = get_nb_pages.item(0).firstChild.data book_info.append(int(nb_pages)) except AttributeError: nb_pages = "" book_info.append(str(nb_pages)) try: get_pub_date = xmldoc.getElementsByTagName('PublicationDate') pub_date = get_pub_date.item(0).firstChild.data book_info.append(str(pub_date)) except AttributeError: pub_date = "" book_info.append(str(pub_date)) try: get_title = xmldoc.getElementsByTagName('Title') title = get_title.item(0).firstChild.data book_info.append(str(title)) except AttributeError: title = "" book_info.append(str(title)) try: get_edition = xmldoc.getElementsByTagName('Edition') edition = get_edition.item(0).firstChild.data book_info.append(str(edition)) except AttributeError: edition = "" book_info.append(str(edition)) cover_xml = urllib.urlopen('http://ecs.amazonaws.com/onca/xml' \ '?Service=AWSECommerceService&AWSAccessKeyId=' \ + CFG_BIBCIRCULATION_AMAZON_ACCESS_KEY + \ '&Operation=ItemSearch&Condition=All&' \ 'ResponseGroup=Images&SearchIndex=Books&' \ 'Keywords=' + isbn) xml_img = minidom.parse(cover_xml) try: get_cover_link = xml_img.getElementsByTagName('MediumImage') cover_link = get_cover_link.item(0).firstChild.firstChild.data book_info.append(str(cover_link)) except AttributeError: cover_link = CFG_SITE_URL + "/img/book_cover_placeholder.gif" book_info.append(str(cover_link)) if len(errors)!=0: body = bibcirculation_templates.tmpl_new_item(errors=errors, ln=ln) else: body = bibcirculation_templates.tmpl_new_item(book_info=book_info, ln=ln) else: body = bibcirculation_templates.tmpl_new_item(ln=ln) return page(title="New Item", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def add_new_library_step1(req, ln=CFG_SITE_LANG): """ Add a new Library. """ navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_add_new_library_step1(ln=ln) return page(title="Add new library", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def add_new_library_step2(req, name, email, phone, address, lib_type, notes, ln=CFG_SITE_LANG): """ Add a new Library. """ tup_infos = (name, email, phone, address, lib_type, notes) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_add_new_library_step2(tup_infos=tup_infos, ln=ln) return page(title="Add new library", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def add_new_library_step3(req, tup_infos, ln=CFG_SITE_LANG): """ Add a new Library. """ (name, email, phone, address, lib_type, notes) = tup_infos db.add_new_library(name, email, phone, address, lib_type, notes) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_add_new_library_step3(ln=ln) return page(title="Add new library", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def update_library_info_step1(req, ln=CFG_SITE_LANG): """ Update the library's information. """ infos = [] navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_update_library_info_step1(infos=infos, ln=ln) return page(title="Update library information", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def update_library_info_step2(req, column, string, ln=CFG_SITE_LANG): """ Update the library's information. """ if not string: infos = [] infos.append("Empty string. Please try again.") body = bibcirculation_templates.tmpl_update_library_info_step1(infos=infos, ln=ln) elif string == '*': result = db.get_all_libraries() body = bibcirculation_templates.tmpl_update_library_info_step2(result=result, ln=ln) else: if column == 'name': result = db.search_library_by_name(string) else: result = db.search_library_by_email(string) body = bibcirculation_templates.tmpl_update_library_info_step2(result=result, ln=ln) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) return page(title="Update library information", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def update_library_info_step3(req, library_id, ln=CFG_SITE_LANG): """ Update the library's information. library_id - identify the library. It is also the primary key of the table crcLIBRARY. """ library_info = db.get_library_details(library_id) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_update_library_info_step3(library_info=library_info, ln=ln) return page(title="Update library information", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def update_library_info_step4(req, name, email, phone, address, library_id, ln=CFG_SITE_LANG): """ Update the library's information. """ tup_infos = (library_id, name, email, phone, address) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_update_library_info_step4(tup_infos=tup_infos, ln=ln) return page(title="Update library information", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def update_library_info_step5(req, tup_infos, ln=CFG_SITE_LANG): """ Update the library's information. """ (library_id, name, email, phone, address) = tup_infos db.update_library_info(library_id, name, email, phone, address) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_update_library_info_step5(ln=ln) return page(title="Update library information", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def new_book_step1(req,ln): """ Add a new book. """ navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_new_book_step1(ln) return page(title="Order New Book", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def new_book_step2(req,ln): """ Add a new book. """ navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_new_book_step2(ln) return page(title="Order New Book", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def add_new_copy_step1(req): """ Add a new copy. """ navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_add_new_copy_step1() return page(title="Associate copy to item", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def add_new_copy_step2(req, p, f, ln=CFG_SITE_LANG): """ Add a new copy. """ result = perform_request_search(cc="Books", sc="1", p=p, f=f) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_add_new_copy_step2(result=result, ln=ln) return page(title="Add new copy - II", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def add_new_copy_step3(req, recid, ln=CFG_SITE_LANG): """ Add a new copy. """ infos = [] result = db.get_item_copies_details(recid) libraries = db.get_libraries() navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_add_new_copy_step3(recid=recid, result=result, libraries=libraries, infos=infos, ln=ln) return page(title="Add new copy - III", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def add_new_copy_step4(req, barcode, library, location, collection, description, loan_period, status, recid, ln=CFG_SITE_LANG): """ Add a new copy. """ infos = [] if db.barcode_in_use(barcode): infos.append("The given barcode %s is already in use." % barcode) result = db.get_item_copies_details(recid) libraries = db.get_libraries() title="Add new copy - III" body = bibcirculation_templates.tmpl_add_new_copy_step3(recid=recid, result=result, libraries=libraries, infos=infos, ln=ln) elif not barcode: infos.append("The given barcode is empty.") result = db.get_item_copies_details(recid) libraries = db.get_libraries() title="Add new copy - III" body = bibcirculation_templates.tmpl_add_new_copy_step3(recid=recid, result=result, libraries=libraries, infos=infos, ln=ln) else: library_name = db.get_library_name(library) tup_infos = (barcode, library, library_name, location, collection, description, loan_period, status, recid) title="Add new copy - IV" body = bibcirculation_templates.tmpl_add_new_copy_step4(tup_infos=tup_infos, ln=ln) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) return page(title=title, uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def add_new_copy_step5(req, tup_infos, ln=CFG_SITE_LANG): """ Add a new copy. """ db.add_new_copy(tup_infos[0], tup_infos[8], tup_infos[1], tup_infos[4], tup_infos[3], tup_infos[5], tup_infos[6], tup_infos[7]) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_add_new_copy_step5(recid=tup_infos[8], ln=ln) return page(title="Add new copy - V", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def update_item_info_step1(req, ln=CFG_SITE_LANG): """ Update the item's information. """ navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_update_item_info_step1(ln=ln) return page(title="Update item information", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def update_item_info_step2(req, p, f, ln=CFG_SITE_LANG): """ Update the item's information. """ result = perform_request_search(cc="Books", sc="1", p=p, f=f) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_update_item_info_step2(result=result, ln=ln) return page(title="Update item information", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def update_item_info_step3(req, recid, ln=CFG_SITE_LANG): """ Update the item's information. """ result = db.get_item_copies_details(recid) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_update_item_info_step3(recid=recid, result=result, ln=ln) return page(title="Update item information", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def update_item_info_step4(req, barcode, ln=CFG_SITE_LANG): """ Update the item's information. """ recid = db.get_id_bibrec(barcode) result = db.get_item_info(barcode) libraries = db.get_libraries() f = open("/tmp/lib","w") f.write(str(libraries)+'\n') f.close() navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_update_item_info_step4(recid=recid, result=result, libraries=libraries, ln=ln) return page(title="Update item information", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def update_item_info_step5(req, barcode, library, location, collection, description, loan_period, status, recid, ln=CFG_SITE_LANG): """ Update the item's information. """ library_name = db.get_library_name(library) tup_infos = (barcode, library, library_name, location, collection, description, loan_period, status, recid) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_update_item_info_step5(tup_infos=tup_infos, ln=ln) return page(title="Update item information", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def update_item_info_step6(req, tup_infos, ln=CFG_SITE_LANG): """ Update the item's information. """ infos = [] # tuple containing information for the update process. (barcode, library_id, _library_name, location, collection, description, loan_period, status, recid) = tup_infos is_on_loan = db.is_on_loan(barcode) is_requested = db.is_requested(barcode) # if item on loan and new status is available, # item has to be returned. if is_on_loan and status == 'available': #borrower_id = db.get_borrower_id(barcode) #borrower_name = db.get_borrower_name(borrower_id) db.update_item_status('available', barcode) db.update_loan_info(datetime.date.today(), 'returned', barcode) # if item requested and new status is available # request has to be cancelled. elif is_requested and status == 'available': for i in range(len(is_requested)): db.update_loan_request_status(is_requested[i][0],'cancelled') # update item information. db.update_item_info(barcode, library_id, collection, location, description, loan_period, status) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) infos.append("Item [%s] updated with success." % barcode) copies = db.get_item_copies_details(recid) requests = db.get_item_requests(recid) loans = db.get_item_loans(recid) req_hist_overview = db.get_item_requests_historical_overview(recid) loans_hist_overview = db.get_item_loans_historical_overview(recid) body = bibcirculation_templates.tmpl_get_item_details(recid=recid, copies=copies, requests=requests, loans=loans, req_hist_overview = req_hist_overview, loans_hist_overview = loans_hist_overview, infos=infos, ln=ln) return page(title="Update copy information - VI", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def search_library_step1(req, ln=CFG_SITE_LANG): """ Display the form where we can search a library (by name or email). """ infos = [] navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_search_library_step1(infos=infos, ln=ln) return page(title="Search library", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def search_library_step2(req, column, string, ln=CFG_SITE_LANG): """ Search a library and return a list with all the possible results, using the parameters received from the previous step. column - identify the column, of the table crcLIBRARY, who will be considered during the search. Can be 'name' or 'email'. str - string used for the search process. """ if not string: infos = [] infos.append("Emptry string. Please try again.") body = bibcirculation_templates.tmpl_search_library_step1(infos=infos, ln=ln) elif string == '*': result = db.get_all_libraries() body = bibcirculation_templates.tmpl_search_library_step2(result=result, ln=ln) else: if column == 'name': result = db.search_library_by_name(string) else: result = db.search_library_by_email(string) body = bibcirculation_templates.tmpl_search_library_step2(result=result, ln=ln) navtrail_previous_links = 'Admin Area' \ ' > Circulation Management' \ ' ' % (CFG_SITE_URL, CFG_SITE_URL) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) return page(title="Search library", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def get_library_notes(req, library_id, delete_key, library_notes, ln=CFG_SITE_LANG): """ Retrieve notes related with a library. library_id - identify the library. It is also the primary key of the table crcLIBRARY. """ if delete_key and library_id: lib_notes = eval(db.get_library_notes(library_id)) del lib_notes[delete_key] db.update_library_notes(library_id, lib_notes) elif library_notes: if db.get_library_notes(library_id): lib_notes = eval(db.get_library_notes(library_id)) else: lib_notes = {} lib_notes[time.strftime("%Y-%m-%d %H:%M:%S")] = str(library_notes) db.update_library_notes(library_id, lib_notes) lib_notes = db.get_library_notes(library_id) navtrail_previous_links = 'Admin Area' \ ' > Circulation Management' \ ' ' % (CFG_SITE_URL, CFG_SITE_URL) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_library_notes(library_notes=lib_notes, library_id=library_id, ln=ln) return page(title="Library notes", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def change_due_date_step1(req, loan_id, borrower_id, ln=CFG_SITE_LANG): """ Change the due date of a loan, step1. loan_id: identify a loan. It is the primery key of the table crcLOAN. borrower_id: identify the borrower. It is also the primary key of the table crcBORROWER. """ loan_details = db.get_loan_infos(loan_id) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_change_due_date_step1(loan_details=loan_details, loan_id=loan_id, borrower_id=borrower_id, ln=ln) return page(title="Change due date", uid=id_user, req=req, body=body, metaheaderadd = "" % CFG_SITE_URL, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def change_due_date_step2(req, new_due_date, loan_id, borrower_id, ln=CFG_SITE_LANG): """ Change the due date of a loan, step2. due_date: new due date. loan_id: identify a loan. It is the primery key of the table crcLOAN. borrower_id: identify the borrower. It is also the primary key of the table crcBORROWER. """ db.update_due_date(loan_id, new_due_date) due_date = db.get_loan_due_date(loan_id) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_change_due_date_step2(new_due_date=new_due_date, borrower_id=borrower_id, ln=ln) return page(title="Change due date", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def claim_book_return(req, borrower_id, recid, loan_id, template, ln=CFG_SITE_LANG): """ Claim the return of an item. borrower_id: identify the borrower. It is also the primary key of the table crcBORROWER. recid: identify the record. It is also the primary key of the table bibrec. template: letter template. """ body = generate_email_body(load_template(template), loan_id) email = db.get_borrower_email(borrower_id) subject = "%s" % (book_title_from_MARC(int(recid))) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_borrower_notification(email=email, subject=subject, template=body, borrower_id=borrower_id, ln=ln) return page(title="Claim return", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def create_new_loan_step1(req, borrower_id, ln=CFG_SITE_LANG): """ Create a new loan from the borrower's page, step1. borrower_id: identify the borrower. It is also the primary key of the table crcBORROWER. """ infos = [] borrower = db.get_borrower_details(borrower_id) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_create_new_loan_step1(borrower=borrower, infos=infos, ln=ln) return page(title="New loan", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def create_new_loan_step2(req, borrower_id, barcode, notes, ln=CFG_SITE_LANG): """ Create a new loan from the borrower's page, step2. borrower_id: identify the borrower. It is also the primary key of the table crcBORROWER. barcode: identify the item. It is the primary key of the table crcITEM. notes: notes about the new loan. """ #borrower_info = db.get_borrower_data(borrower_id) has_recid = db.get_id_bibrec(barcode) loan_id = db.is_item_on_loan(barcode) if notes: notes_format = '[' + time.ctime() + '] ' + notes + '\n' else: notes_format = '' infos = [] if has_recid is None: infos.append('"%s" > Unknown barcode. Please try again.' % barcode) borrower = db.get_borrower_details(borrower_id) title="New loan" body = bibcirculation_templates.tmpl_create_new_loan_step1(borrower=borrower, infos=infos, ln=ln) elif loan_id: infos.append('The item with the barcode "%s" is on loan.' % barcode) borrower = db.get_borrower_details(borrower_id) title="New loan" body = bibcirculation_templates.tmpl_create_new_loan_step1(borrower=borrower, infos=infos, ln=ln) else: loaned_on = datetime.date.today() due_date = renew_loan_for_X_days(barcode) db.new_loan(borrower_id, has_recid, barcode, loaned_on, due_date, 'on loan', 'normal', notes_format) result = db.get_all_loans(20) title = "Current loans" infos.append('A new loan has been registered with success.') body = bibcirculation_templates.tmpl_all_loans(result=result, infos=infos, ln=ln) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) return page(title=title, uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def create_new_request_step1(req, borrower_id, p="", f="", search=None, ln=CFG_SITE_LANG): """ Create a new request from the borrower's page, step1. borrower_id: identify the borrower. It is also the primary key of the table crcBORROWER. p: search pattern. f: field search: search an item. """ infos = [] borrower = db.get_borrower_details(borrower_id) if p == '': infos.append('Empty string. Please, try again.') result = '' elif search and f == 'barcode': has_recid = db.get_recid(p) if has_recid is None: infos.append('The barcode %s does not exist on BibCirculation database.' % p) result = '' else: result = has_recid elif search: result = perform_request_search(cc="Books", sc="1", p=p, f=f) else: result = '' navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_create_new_request_step1(borrower=borrower, infos=infos, result=result, p=p, f=f, ln=ln) return page(title="New request", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def create_new_request_step2(req, recid, borrower_id, ln=CFG_SITE_LANG): """ Create a new request from the borrower's page, step2. recid: identify the record. It is also the primary key of the table bibrec. borrower_id: identify the borrower. It is also the primary key of the table crcBORROWER. """ holdings_information = db.get_holdings_information(recid) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) user_info = db.get_borrower_details(borrower_id) body = bibcirculation_templates.tmpl_create_new_request_step2(user_info = user_info, holdings_information = holdings_information, recid=recid, ln=ln) return page(title="New request", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def create_new_request_step3(req, borrower_id, barcode, recid, ln=CFG_SITE_LANG): """ Create a new request from the borrower's page, step3. borrower_id: identify the borrower. It is also the primary key of the table crcBORROWER. barcode: identify the item. It is the primary key of the table crcITEM. recid: identify the record. It is also the primary key of the table bibrec. """ navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) item_info = db.get_item_info(barcode) if item_info[6] == 'Not for loan': body = bibcirculation_templates.tmpl_book_not_for_loan(ln=ln) else: body = bibcirculation_templates.tmpl_create_new_request_step3(borrower_id=borrower_id, barcode=barcode, recid=recid, ln=ln) return page(title="New request", uid=id_user, req=req, body=body, metaheaderadd = "" % CFG_SITE_URL, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def create_new_request_step4(req, period_from, period_to, barcode, borrower_id, recid, ln=CFG_SITE_LANG): """ Create a new request from the borrower's page, step4. period_from: begining of the period of interest. period_to: end of the period of interest. barcode: identify the item. It is the primary key of the table crcITEM. borrower_id: identify the borrower. It is also the primary key of the table crcBORROWER. recid: identify the record. It is also the primary key of the table bibrec. """ 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' db.new_hold_request(borrower_id, recid, barcode, period_from, period_to, status) db.update_item_status('requested', barcode) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_create_new_request_step4(ln=ln) return page(title="New request", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def place_new_request_step1(req, barcode, recid, key, string, ln=CFG_SITE_LANG): """ Place a new request from the item's page, step1. barcode: identify the item. It is the primary key of the table crcITEM. recid: identify the record. It is also the primary key of the table bibrec. key: search field. string: search pattern. """ recid = db.get_id_bibrec(barcode) infos = [] if key and not string: infos.append('Empty string. Please, try again.') body = bibcirculation_templates.tmpl_place_new_request_step1(result=None, key=key, string=string, barcode=barcode, recid=recid, infos=infos, ln=ln) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) return page(title="New request", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) list_infos = [] if CFG_CERN_SITE == 1: if key =='ccid' and string: from invenio.bibcirculation_cern_ldap import get_user_info_from_ldap result = get_user_info_from_ldap(ccid=string) try: name = result['cn'][0] except KeyError: name = "" try: ccid = result['employeeID'][0] except KeyError: ccid = "" try: email = result['mail'][0] except KeyError: email = "" try: phone = result['telephoneNumber'][0] except KeyError: phone = "" try: address = result['physicalDeliveryOfficeName'][0] except KeyError: address = "" try: mailbox = result['postOfficeBox'][0] except KeyError: mailbox = "" tup = ('',ccid, name, email, phone, address, mailbox) list_infos.append(tup) elif key =='name' and string: result = db.get_borrower_data_by_name(string) for (borrower_id, ccid, name, email, phone, address, mailbox) in result: tup = (borrower_id, ccid, name, email, phone, address, mailbox) list_infos.append(tup) elif key =='email' and string: result = db.get_borrower_data_by_email(string) for (borrower_id, ccid, name, email, phone, address, mailbox) in result: tup = (borrower_id, ccid, name, email, phone, address, mailbox) list_infos.append(tup) else: result = list_infos else: if key =='name' and string: result = db.get_borrower_data_by_name(string) elif key =='email' and string: result = db.get_borrower_data_by_email(string) else: result = db.get_borrower_data_by_id(string) for (borrower_id, ccid, name, email, phone, address, mailbox) in result: tup = (borrower_id, ccid, name, email, phone, address, mailbox) list_infos.append(tup) if len(result) == 1: return place_new_request_step2(req, barcode, recid, tup, ln) else: body = bibcirculation_templates.tmpl_place_new_request_step1(result=list_infos, key=key, string=string, barcode=barcode, recid=recid, infos=infos, ln=ln) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) return page(title="New request", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def place_new_request_step2(req, barcode, recid, user_info, ln=CFG_SITE_LANG): """ Place a new request from the item's page, step2. @type barcode: string. @param barcode: identify the item. It is the primary key of the table crcITEM. @type recid: integer. @param recid: identify the record. It is also the primary key of the table bibrec. @type user_info: list. @param user_info: information of the user/borrower who was selected. """ infos = [] body = bibcirculation_templates.tmpl_place_new_request_step2(barcode=barcode, recid=recid, user_info=user_info, infos=infos, ln=ln) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) return page(title="New request", uid=id_user, req=req, body=body, metaheaderadd = "" % CFG_SITE_URL, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def place_new_request_step3(req, barcode, recid, user_info, period_from, period_to, ln=CFG_SITE_LANG): """ Place a new request from the item's page, step3. @type barcode: string. @param barcode: identify the item. It is the primary key of the table crcITEM. @type recid: integer. @param recid: identify the record. It is also the primary key of the table bibrec. @return: new request. """ (id, ccid, name, email, phone, address, mailbox) = user_info # validate the period of interest given by the admin if validate_date_format(period_from) is False: infos = [] infos.append("The period of interest 'From': %s" \ " is not a valid date or date format" % period_from) body = bibcirculation_templates.tmpl_place_new_request_step2(barcode=barcode, recid=recid, user_info=user_info, infos=infos, ln=ln) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) return page(title="New request", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) elif validate_date_format(period_to) is False: infos = [] infos.append("The period of interest 'To': %s" \ " is not a valid date or date format" % period_to) body = bibcirculation_templates.tmpl_place_new_request_step2(barcode=barcode, recid=recid, user_info=user_info, infos=infos, ln=ln) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) return page(title="New request", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) # Register request 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' is_borrower = db.is_borrower(email) if is_borrower == 0: db.new_borrower(ccid, name, email, phone, address, mailbox, '') is_borrower = db.is_borrower(email) req_id = db.new_hold_request(is_borrower, recid, barcode, period_from, period_to, status) db.update_item_status('requested', barcode) if status == 'pending': (title, year, author, isbn, publisher) = book_information_from_MARC(int(recid)) details = db.get_loan_request_details(req_id) if details: library = details[3] location = details[4] request_date = details[7] else: location = '' library = '' request_date = '' link_to_holdings_details = create_html_link(CFG_SITE_URL + '/record/%s/holdings'%str(recid), {'ln': ln}, (CFG_SITE_URL + '/record/%s/holdings'%str(recid))) subject = 'New request' message = load_template('notification') message = message % (name, ccid, email, address, mailbox, title, author, publisher, year, isbn, location, library, link_to_holdings_details, request_date) send_email(fromaddr = CFG_BIBCIRCULATION_LIBRARIAN_EMAIL, - toaddr = CFG_BIBCIRCULATION_LIBRARIAN_EMAIL, + toaddr = CFG_BIBCIRCULATION_LOANS_EMAIL, subject = subject, content = message, header = '', footer = '', attempt_times=1, attempt_sleeptime=10 ) send_email(fromaddr = CFG_BIBCIRCULATION_LIBRARIAN_EMAIL, toaddr = email, subject = subject, content = message, header = '', footer = '', attempt_times=1, attempt_sleeptime=10 ) body = bibcirculation_templates.tmpl_place_new_request_step3(ln=ln) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) return page(title="New request", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def place_new_loan_step1(req, barcode, recid, key, string, ln=CFG_SITE_LANG): """ Place a new loan from the item's page, step1. @type barcode: string. @param barcode: identify the item. It is the primary key of the table crcITEM. @type recid: integer. @param recid: identify the record. It is also the primary key of the table bibrec. @type key: string. @param key: search field. @type string: string. @param string: search pattern. @return: list of users/borrowers. """ recid = db.get_id_bibrec(barcode) infos = [] if key and not string: infos.append('Empty string. Please, try again.') body = bibcirculation_templates.tmpl_place_new_loan_step1(result=None, key=key, string=string, barcode=barcode, recid=recid, infos=infos, ln=ln) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) return page(title="New loan", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) list_infos = [] if CFG_CERN_SITE == 1: if key =='ccid' and string: from invenio.bibcirculation_cern_ldap import get_user_info_from_ldap result = get_user_info_from_ldap(ccid=string) try: name = result['cn'][0] except KeyError: name = "" try: ccid = result['employeeID'][0] except KeyError: ccid = "" try: email = result['mail'][0] except KeyError: email = "" try: phone = result['telephoneNumber'][0] except KeyError: phone = "" try: address = result['physicalDeliveryOfficeName'][0] except KeyError: address = "" try: mailbox = result['postOfficeBox'][0] except KeyError: mailbox = "" tup = ('', ccid, name, email, phone, address, mailbox) list_infos.append(tup) elif key =='name' and string: result = db.get_borrower_data_by_name(string) for (borrower_id, ccid, name, email, phone, address, mailbox) in result: tup = (borrower_id, ccid, name, email, phone, address, mailbox) list_infos.append(tup) elif key =='email' and string: result = db.get_borrower_data_by_email(string) for (borrower_id, ccid, name, email, phone, address, mailbox) in result: tup = (borrower_id, ccid, name, email, phone, address, mailbox) list_infos.append(tup) else: list_infos = [] else: if key =='name' and string: result = db.get_borrower_data_by_name(string) elif key =='email' and string: result = db.get_borrower_data_by_email(string) else: result = db.get_borrower_data_by_id(string) for (borrower_id, ccid, name, email, phone, address, mailbox) in result: tup = (borrower_id, ccid, name, email, phone, address, mailbox) list_infos.append(tup) body = bibcirculation_templates.tmpl_place_new_loan_step1(result=list_infos, key=key, string=string, barcode=barcode, recid=recid, infos=infos, ln=ln) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) return page(title="New loan", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def place_new_loan_step2(req, barcode, recid, user_info, ln=CFG_SITE_LANG): """ Place a new loan from the item's page, step2. @type barcode: string. @param barcode: identify the item. It is the primary key of the table crcITEM. @type recid: integer. @param recid: identify the record. It is also the primary key of the table bibrec. @type user_info: list. @param user_info: information of the user/borrower who was selected. """ body = bibcirculation_templates.tmpl_place_new_loan_step2(barcode=barcode, recid=recid, user_info=user_info, ln=ln) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) return page(title="New loan", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def place_new_loan_step3(req, barcode, recid, ccid, name, email, phone, address, mailbox, due_date, notes, ln=CFG_SITE_LANG): """ Place a new loan from the item's page, step3. @type barcode: string. @param barcode: identify the item. It is the primary key of the table crcITEM. @type recid: integer. @param recid: identify the record. It is also the primary key of the table bibrec. @type name: string. @type email: string. @type phone: string. @type address: string. @type mailbos: string. @type due_date: string. @type notes: string. @return: new loan. """ infos = [] if notes: notes_format = '[' + time.ctime() + '] ' + notes + '\n' else: notes_format = '' loaned_on = datetime.date.today() is_borrower = db.is_borrower(email) borrower_info = db.get_borrower_data(is_borrower) if db.is_on_loan(barcode): infos.append("Item with barcode %s is already on loan." % barcode) copies = db.get_item_copies_details(recid) requests = db.get_item_requests(recid) loans = db.get_item_loans(recid) req_hist_overview = db.get_item_requests_historical_overview(recid) loans_hist_overview = db.get_item_loans_historical_overview(recid) title = "Item details" body = bibcirculation_templates.tmpl_get_item_details(recid=recid, copies=copies, requests=requests, loans=loans, req_hist_overview = req_hist_overview, loans_hist_overview = loans_hist_overview, infos=infos, ln=ln) elif is_borrower != 0: db.new_loan(is_borrower, recid, barcode, loaned_on, due_date, 'on loan', 'normal', notes_format) db.update_item_status('on loan', barcode) title = "New loan" body = bibcirculation_templates.tmpl_register_new_loan(borrower_info=borrower_info, recid=recid, ln=ln) else: db.new_borrower(ccid, name, email, phone, address, mailbox, '') is_borrower = db.is_borrower(email) db.new_loan(is_borrower, recid, barcode, loaned_on, due_date, 'on loan', 'normal', notes_format) db.update_item_status('on loan', barcode) title = "New loan" body = bibcirculation_templates.tmpl_register_new_loan(borrower_info=borrower_info, recid=recid, ln=ln) navtrail_previous_links = 'Admin Area' \ ' > Circulation Management' \ ' ' % (CFG_SITE_URL, CFG_SITE_URL) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) return page(title=title, uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def order_new_copy_step1(req, recid, ln): """ Order a new copy. Step 1. """ list_of_vendors = db.get_list_of_vendors() libraries = db.get_libraries() body = bibcirculation_templates.tmpl_order_new_copy_step1(recid=recid, list_of_vendors=list_of_vendors, libraries=libraries, ln=ln) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) return page(title="Order new copy", uid=id_user, req=req, metaheaderadd = "" % CFG_SITE_URL, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def order_new_copy_step2 (req, recid, barcode, vendor_id, cost, currency, status, order_date, expected_date, library_id, notes, ln): """ Order a new copy. Step 2. """ order_info = (recid, barcode, vendor_id, cost, currency, status, order_date, expected_date, library_id, notes) body = bibcirculation_templates.tmpl_order_new_copy_step2(order_info=order_info, ln=ln) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) return page(title="Order new copy", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def order_new_copy_step3(req, order_info, ln): """ Order a new copy. Step 3. """ (recid, _barcode, vendor_id, cost, currency, status, order_date, expected_date, _library_id, notes) = order_info cost_format = cost + ' ' + currency purchase_notes = {time.strftime("%Y-%m-%d %H:%M:%S"): notes} db.order_new_copy(recid, vendor_id, order_date, cost_format, status, str(purchase_notes), expected_date) #db.add_new_copy(barcode, recid, library_id, '', '', # 'expected: %s' % expected_date, '', status) #body = list_ordered_books(req,ln) #bibcirculation_templates.tmpl_order_new_copy_step3(ln=ln) #navtrail_previous_links = 'Admin Area' \ # '' % (CFG_SITE_URL,) #id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) #return page(title="Order new copy", # uid=id_user, # req=req, # body=body, # navtrail=navtrail_previous_links, # lastupdated=__lastupdated__) return get_item_details(req, recid, ln) def list_ordered_books(req, ln): """ Return the list with all ordered books. """ ordered_books = db.get_ordered_books() body = bibcirculation_templates.tmpl_ordered_books(ordered_books=ordered_books, ln=ln) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) return page(title="List of ordered books", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def get_purchase_notes(req, purchase_id, delete_key, library_notes, ln=CFG_SITE_LANG): """ Retrieve notes related with a library. purchase_id - identify the purchase. It is also the primary key of the table crcPURCHASE. @param add_notes: display the textarea where will be written a new notes. @param new_notes: note who will be added to the others library's notes. """ if delete_key and purchase_id: purchase_notes = eval(db.get_purchase_notes(purchase_id)) del purchase_notes[delete_key] db.update_purchase_notes(purchase_id, purchase_notes) elif library_notes: if db.get_purchase_notes(purchase_id): purchase_notes = eval(db.get_purchase_notes(purchase_id)) else: purchase_notes = {} purchase_notes[time.strftime("%Y-%m-%d %H:%M:%S")] = str(library_notes) db.update_purchase_notes(purchase_id, purchase_notes) purchase_notes = db.get_purchase_notes(purchase_id) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_purchase_notes(purchase_notes=purchase_notes, purchase_id=purchase_id, ln=ln) return page(title="Purchase notes", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def register_ill_request_step0(req, recid, key, string, ln=CFG_SITE_LANG): """ Place a new request from the item's page, step1. barcode: identify the item. It is the primary key of the table crcITEM. recid: identify the record. It is also the primary key of the table bibrec. key: search field. string: search pattern. """ if string == '': message = 'Empty string. Please, try again.' return borrower_search(req, message, redirect, ln) else: result = search_user(key, string) infos = [] if not key or (key and not string): if key and not string: infos.append("Empty string. Please try again.") body = bibcirculation_templates.tmpl_register_ill_request_step0(result=None, infos=infos, key=key, string=string, recid=recid, ln=ln) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) return page(title="Register ILL request", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) if CFG_CERN_SITE == 1: if key == 'name': result = db.search_borrower_by_name(string) elif key == 'email': result = db.search_borrower_by_email(string) else: result = db.search_borrower_by_ccid(int(string)) if result == (): from invenio.bibcirculation_cern_ldap import get_user_info_from_ldap ldap_info = get_user_info_from_ldap(ccid=string) if len(ldap_info) == 0: result = () else: if ldap_info == 'busy': message = bibcirculation_templates.tmpl_message_sever_busy(ln) return borrower_search(req, message, redirect, ln) else: try: name = ldap_info['cn'][0] except KeyError: name = "" try: email = ldap_info['mail'][0] except KeyError: email = "" try: phone = ldap_info['telephoneNumber'][0] except KeyError: phone = "" try: address = ldap_info['physicalDeliveryOfficeName'][0] except KeyError: address = "" try: mailbox = ldap_info['postOfficeBox'][0] except KeyError: mailbox = "" try: ccid = ldap_info['employeeID'][0] except KeyError: ccid = "" db.new_borrower(ccid, name, email, phone, address, mailbox, '') result = db.search_borrower_by_ccid(int(ccid)) else: if key == 'name': result = db.search_borrower_by_name(string) elif key == 'email': result = db.search_borrower_by_email(string) else: result = db.search_borrower_by_id(string) for (borrower_id, ccid, name, email, phone, address, mailbox) in result: tup = (borrower_id, ccid, name, email, phone, address, mailbox) list_infos.append(tup) body = bibcirculation_templates.tmpl_register_ill_request_step0(result=result, infos=infos, key=key, string=string, recid=recid, ln=ln) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) return page(title="Register ILL request", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def register_ill_request_step1(req, recid, user_info, ln=CFG_SITE_LANG): """ Register a new ILL request. Step 1. """ navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_register_ill_request_step1(recid=recid, user_info=user_info, ln=ln) return page(title="Register ILL request", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def register_ill_request_step2(req, recid, user_info, period_of_interest_from, period_of_interest_to, notes, only_edition, ln=CFG_SITE_LANG): """ """ request_info = (recid, period_of_interest_from, period_of_interest_to, notes, only_edition) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_register_ill_request_step2(user_info=user_info, request_info=request_info, ln=ln) return page(title="Register ILL request", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def register_ill_request_step3(req, borrower_id, request_info, ln=CFG_SITE_LANG): """ """ (recid, period_of_interest_from, period_of_interest_to, notes, only_edition) = request_info book_info = {'recid': recid} if notes: library_notes = {} library_notes[time.strftime("%Y-%m-%d %H:%M:%S")] = str(notes) else: library_notes = {} db.ill_register_request_on_desk(borrower_id, book_info, period_of_interest_from, period_of_interest_to, 'pending', str(library_notes), only_edition or 'No', 'book') navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_register_ill_request_step3(ln=ln) return page(title="Register ILL request", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def list_ill_request(req, status, ln=CFG_SITE_LANG): """ """ navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) ill_req = db.get_ill_requests(status) body = bibcirculation_templates.tmpl_list_ill_request(ill_req=ill_req, ln=ln) return page(title="List of ILL requests", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def ill_request_details_step1(req, delete_key, ill_request_id, new_status, ln=CFG_SITE_LANG): """ """ if delete_key and ill_request_id: library_notes = eval(db.get_ill_request_notes(ill_request_id)) del library_notes[delete_key] db.update_ill_request_notes(ill_request_id, library_notes) if new_status: db.update_ill_request_status(ill_request_id,new_status) ill_request_borrower_details = db.get_ill_request_borrower_details(ill_request_id) ill_request_details=db.get_ill_request_details(ill_request_id) libraries = db.get_external_libraries() navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_ill_request_details_step1(ill_request_id=ill_request_id, ill_request_details=ill_request_details, libraries=libraries, ill_request_borrower_details=ill_request_borrower_details, ln=ln) return page(title="ILL request details", uid=id_user, req=req, metaheaderadd = "" % CFG_SITE_URL, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def ill_request_details_step2(req, delete_key, ill_request_id, new_status, library_id, request_date, expected_date, arrival_date, due_date, return_date, cost, currency, barcode, library_notes, ln=CFG_SITE_LANG): """ """ #id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) if delete_key and ill_request_id: library_previous_notes = eval(db.get_ill_request_notes(ill_request_id)) del library_previous_notes[delete_key] db.update_ill_request_notes(ill_request_id, library_previous_notes) #navtrail_previous_links = 'Admin Area' \ # '' % (CFG_SITE_URL,) cost_format = None if cost: cost_format = cost + ' ' + currency if db.get_ill_request_notes(ill_request_id): library_previous_notes = eval(db.get_ill_request_notes(ill_request_id)) else: library_previous_notes = {} if library_notes: library_previous_notes[time.strftime("%Y-%m-%d %H:%M:%S")] = str(library_notes) if new_status == 'on loan': borrower_id = db.get_ill_borrower(ill_request_id) loaned_on = datetime.date.today() db.new_loan(borrower_id, '0', barcode, loaned_on, due_date, 'on loan', 'ill','') elif new_status == 'returned': borrower_id = db.get_ill_borrower(ill_request_id) barcode = db.get_ill_barcode(ill_request_id) db.update_ill_loan_status(borrower_id, barcode, return_date, 'ill') db.update_ill_request(ill_request_id, library_id, request_date, expected_date, arrival_date, due_date, return_date, new_status, cost_format, barcode, str(library_previous_notes)) return list_ill_request(req,new_status,ln) #body = bibcirculation_templates.tmpl_ill_request_details_step3(ln=ln) #return page(title="ILL request details", # uid=id_user, # req=req, # body=body, # navtrail=navtrail_previous_links, # lastupdated=__lastupdated__) def ordered_books_details_step1(req, purchase_id, delete_key, ln=CFG_SITE_LANG): """ """ if delete_key and purchase_id: purchase_notes = eval(db.get_purchase_notes(purchase_id)) del purchase_notes[delete_key] db.update_purchase_notes(purchase_id, purchase_notes) list_of_vendors = db.get_list_of_vendors() order_details = db.get_order_details(purchase_id) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_ordered_book_details_step1(order_details=order_details, list_of_vendors=list_of_vendors, ln=ln) return page(title="Ordered book details", uid=id_user, req=req, metaheaderadd = "" % CFG_SITE_URL, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def ordered_books_details_step2(req, purchase_id, recid, vendor_id, cost, currency, status, order_date, expected_date, purchase_notes, library_notes, ln=CFG_SITE_LANG): """ """ order_details = (purchase_id, recid, vendor_id, cost, currency, status, order_date, expected_date, purchase_notes, library_notes) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_ordered_book_details_step2(order_details=order_details, ln=ln) return page(title="Ordered book details", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def ordered_books_details_step3(req, purchase_id, recid, vendor_id, cost, currency, status, order_date, expected_date, purchase_notes, library_notes, ln=CFG_SITE_LANG): """ """ purchase_notes = eval(purchase_notes) library_notes = library_notes.strip(' \n\t') if (len(library_notes)) is not 0: purchase_notes[time.strftime("%Y-%m-%d %H:%M:%S")] = str(library_notes) cost_format = cost + ' ' + currency db.uptade_purchase(purchase_id, recid, vendor_id, cost_format, status, order_date, expected_date, str(purchase_notes)) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) #body = bibcirculation_templates.tmpl_ordered_book_details_step3(ln=ln) body = list_ordered_books(req,ln) return page(title="Ordered book details", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def add_new_vendor_step1(req, ln=CFG_SITE_LANG): """ Add a new Vendor. """ navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_add_new_vendor_step1(ln=ln) return page(title="Add new vendor", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def add_new_vendor_step2(req, name, email, phone, address, notes, ln=CFG_SITE_LANG): """ Add a new Vendor. """ tup_infos = (name, email, phone, address, notes) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_add_new_vendor_step2(tup_infos=tup_infos, ln=ln) return page(title="Add new vendor", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def add_new_vendor_step3(req, tup_infos, ln=CFG_SITE_LANG): """ Add a new Vendor. """ (name, email, phone, address, notes) = tup_infos db.add_new_vendor(name, email, phone, address, notes) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_add_new_vendor_step3(ln=ln) return page(title="Add new vendor", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def update_vendor_info_step1(req, ln=CFG_SITE_LANG): """ Update the vendor's information. """ infos = [] navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_update_vendor_info_step1(infos=infos, ln=ln) return page(title="Update vendor information", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def update_vendor_info_step2(req, column, string, ln=CFG_SITE_LANG): """ Update the vendor's information. """ if not string: infos = [] infos.append("Empty string. Please try again.") body = bibcirculation_templates.tmpl_update_vendor_info_step1(infos=infos, ln=ln) elif string == '*': result = db.get_all_vendors() body = bibcirculation_templates.tmpl_update_vendor_info_step2(result=result, ln=ln) else: if column == 'name': result = db.search_vendor_by_name(string) else: result = db.search_vendor_by_email(string) body = bibcirculation_templates.tmpl_update_vendor_info_step2(result=result, ln=ln) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_update_vendor_info_step2(result=result, ln=ln) return page(title="Update vendor information", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def update_vendor_info_step3(req, vendor_id, ln=CFG_SITE_LANG): """ Update the library's information. vendor_id - identify the vendor. It is also the primary key of the table crcVENDOR. """ vendor_info = db.get_vendor_details(vendor_id) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_update_vendor_info_step3(vendor_info=vendor_info, ln=ln) return page(title="Update vendor information", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def update_vendor_info_step4(req, name, email, phone, address, vendor_id, ln=CFG_SITE_LANG): """ Update the vendor's information. """ tup_infos = (vendor_id, name, email, phone, address) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_update_vendor_info_step4(tup_infos=tup_infos, ln=ln) return page(title="Update vendor information", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def update_vendor_info_step5(req, tup_infos, ln=CFG_SITE_LANG): """ Update the library's information. """ (vendor_id, name, email, phone, address) = tup_infos db.update_vendor_info(vendor_id, name, email, phone, address) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_update_vendor_info_step5(ln=ln) return page(title="Update library information - V", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def search_vendor_step1(req, ln=CFG_SITE_LANG): """ Display the form where we can search a vendor (by name or email). """ infos = [] navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_search_vendor_step1(infos=infos, ln=ln) return page(title="Search vendor", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def search_vendor_step2(req, column, string, ln=CFG_SITE_LANG): """ Search a vendor and return a list with all the possible results, using the parameters received from the previous step. column - identify the column, of the table crcVENDOR, who will be considered during the search. Can be 'name' or 'email'. str - string used for the search process. """ if not string: infos = [] infos.append("Empty string. Please try again.") body = bibcirculation_templates.tmpl_search_vendor_step1(infos=infos, ln=ln) elif string == '*': result = db.get_all_vendors() body = bibcirculation_templates.tmpl_search_vendor_step2(result=result, ln=ln) else: if column == 'name': result = db.search_vendor_by_name(string) else: result = db.search_vendor_by_email(string) body = bibcirculation_templates.tmpl_search_vendor_step2(result=result, ln=ln) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) return page(title="Search vendor", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def get_vendor_details(req, vendor_id, ln=CFG_SITE_LANG): """ Display the details of a vendor. @type vendor_id: integer. @param vendor_id: identify the vendor. It is also the primary key of the table crcVENDOR. @return: vendor details. """ vendor_details = db.get_vendor_details(vendor_id) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_vendor_details(vendor_details=vendor_details, ln=ln) return page(title="Vendor details", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def get_vendor_notes(req, vendor_id, add_notes, new_note, ln=CFG_SITE_LANG): """ Retrieve notes related with a vendor. vendor_id - identify the vendor. It is also the primary key of the table crcVENDOR. @param add_notes: display the textarea where will be written a new notes. @param new_notes: note who will be added to the others vendor's notes. """ if new_note: date = '[' + time.ctime() + '] ' new_line = '\n' new_note = date + new_note + new_line db.add_new_vendor_note(new_note, vendor_id) vendor_notes = db.get_vendor_notes(vendor_id) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_vendor_notes(vendor_notes=vendor_notes, vendor_id=vendor_id, add_notes=add_notes, ln=ln) return page(title="Vendor notes", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def register_ill_request_with_no_recid_step1(req, ln=CFG_SITE_LANG): """ """ infos = [] navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_register_ill_request_with_no_recid_step1(infos=infos,ln=ln) return page(title="Register ILL request", uid=id_user, req=req, metaheaderadd = "" % CFG_SITE_URL, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def register_ill_request_with_no_recid_step2(req, title, authors, place, publisher, year, edition, isbn, period_of_interest_from, period_of_interest_to, additional_comments, only_edition, key, string, ln=CFG_SITE_LANG): """ """ infos = [] book_info = (title, authors, place, publisher, year, edition, isbn) request_details = (period_of_interest_from, period_of_interest_to, additional_comments, only_edition) if not key: list = None elif not string: infos.append('Empty string. Please, try again.') list = None else: if validate_date_format(period_of_interest_from) is False: infos = [] infos.append("The given 'period_of_interest_from' %s" \ " is not a valid date or date format" % period_of_interest_from) body = bibcirculation_templates.tmpl_register_ill_request_with_no_recid_step1(infos=infos, ln=ln) elif validate_date_format(period_of_interest_to) is False: infos = [] infos.append("The given 'period_of_interest_to' %s" \ " is not a valid date or date format" % period_of_interest_to) body = bibcirculation_templates.tmpl_register_ill_request_with_no_recid_step1(infos=infos, ln=ln) else: result = search_user(key, string) list = [] if len(result)==0: infos.append("O borrowers found.") else: for user in result: tuple = db.get_borrower_data_by_id(user[0])[0] list.append(tuple) body = bibcirculation_templates.tmpl_register_ill_request_with_no_recid_step2(book_info=book_info, request_details=request_details, result=list, key=key, string=string, infos=infos, ln=ln) navtrail_previous_links = 'Admin Area' \ ' > Circulation Management' \ ' ' % (CFG_SITE_URL, CFG_SITE_URL) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) return page(title="Register ILL request", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def register_ill_request_with_no_recid_step3(req, book_info, user_info, request_details, ln): """ """ navtrail_previous_links = 'Admin Area' \ ' > Circulation Management' \ ' ' % (CFG_SITE_URL, CFG_SITE_URL) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_register_ill_request_with_no_recid_step3(book_info=book_info, user_info=user_info, request_details=request_details, ln=ln) return page(title="Register ILL request", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def register_ill_request_with_no_recid_step4(req, book_info, user_info, request_details, ln): """ """ #id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) (title, authors, place, publisher, year, edition, isbn) = book_info create_ill_record(book_info) book_info = {'title': title, 'authors': authors, 'place': place, 'publisher': publisher, 'year' : year, 'edition': edition, 'isbn' : isbn} (period_of_interest_from, period_of_interest_to, library_notes, only_edition) = request_details (borrower_id, _ccid, _name, _email, _phone, _address, _mailbox) = user_info ill_request_notes = {} if library_notes: ill_request_notes[time.strftime("%Y-%m-%d %H:%M:%S")] = str(library_notes) db.ill_register_request_on_desk(borrower_id, book_info, period_of_interest_from, period_of_interest_to, 'new', str(ill_request_notes), only_edition, 'book') #navtrail_previous_links = 'Admin Area' \ # '' % (CFG_SITE_URL,) return list_ill_request(req, "new", ln) def get_borrower_ill_details(req, borrower_id, ln=CFG_SITE_LANG): """ Display ILL details of a borrower. @type borrower_id: integer. @param borrower_id: identify the borrower. It is also the primary key of the table crcBORROWER. @type ill_id: integer. @param ill_id: identify the ILL request. It is also the primary key of the table crcILLREQUEST. @return: borrower ILL details. """ result = db.get_ill_requests_details(borrower_id) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) name = db.get_borrower_name(borrower_id) title = "ILL details - %s" % (name) body = bibcirculation_templates.tmpl_borrower_ill_details(result=result, borrower_id=borrower_id, ln=ln) return page(title=title, uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def bor_ill_historical_overview(req, borrower_id, ln): result = db.bor_ill_historical_overview(borrower_id) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) name = db.get_borrower_name(borrower_id) title = "ILL historical overview - %s" % (name) body = bibcirculation_templates.tmpl_borrower_ill_details(result=result, borrower_id=borrower_id, ln=ln) return page(title=title, uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def get_ill_library_notes(req, ill_id, delete_key, library_notes, ln=CFG_SITE_LANG): """ """ if delete_key and ill_id: ill_notes = eval(db.get_ill_notes(ill_id)) del ill_notes[delete_key] db.update_ill_notes(ill_id, ill_notes) elif library_notes: if db.get_ill_notes(ill_id): ill_notes = eval(db.get_ill_notes(ill_id)) else: ill_notes = {} ill_notes[time.strftime("%Y-%m-%d %H:%M:%S")] = str(library_notes) db.update_ill_notes(ill_id, ill_notes) ill_notes = db.get_ill_notes(ill_id) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_ill_notes(ill_notes=ill_notes, ill_id=ill_id, ln=ln) return page(title="ILL notes", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def get_expired_loans_with_requests(req, request_id, ln=CFG_SITE_LANG): """ """ if request_id: db.update_loan_request_status(request_id,'cancelled') update_request_data(request_id) result = db.get_expired_loans_with_requests() else: result = db.get_expired_loans_with_requests() navtrail_previous_links = 'Admin Area' \ ' > Circulation Management' \ ' ' % (CFG_SITE_URL, CFG_SITE_URL) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_get_expired_loans_with_requests(result=result, ln=ln) return page(title="Overdue loans with holds", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def register_ill_book_request(req, ln=CFG_SITE_LANG): """ Display a form where is possible to searh for an item. """ navtrail_previous_links = 'Admin Area' \ ' > Circulation Management' \ ' ' % (CFG_SITE_URL, CFG_SITE_URL) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) infos = [] body = bibcirculation_templates.tmpl_register_ill_book_request(infos=infos, ln=ln) return page(title="Register ILL Book request", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def register_ill_book_request_result(req, p, f, ln=CFG_SITE_LANG): """ Search an item and return a list with all the possible results. To retrieve the information desired, we use the method 'perform_request_search' (from search_engine.py). In the case of BibCirculation, we are just looking for books (items) inside the collection 'Books'. @type p: string @param p: search pattern @type f: string @param f: search field @return: list of recids """ infos = [] if p == '': infos.append('Empty string. Please, try again.') body = bibcirculation_templates.tmpl_register_ill_book_request(infos=infos, ln=ln) else: if f == 'barcode': has_recid = db.get_recid(p) if has_recid is None: infos.append('The barcode %s does not exist on BibCirculation database.' % p) body = bibcirculation_templates.tmpl_register_ill_book_request(infos=infos, ln=ln) else: body = bibcirculation_templates.tmpl_register_ill_book_request_result(result=has_recid, ln=ln) else: result = perform_request_search(cc="Books", sc="1", p=p, f=f) if len(result) == 0: return register_ill_request_with_no_recid_step1(req, ln) else: body = bibcirculation_templates.tmpl_register_ill_book_request_result(result=result, ln=ln) navtrail_previous_links = 'Admin Area' \ ' > Circulation Management' \ ' ' % (CFG_SITE_URL, CFG_SITE_URL) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) return page(title="Register ILL Book request", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def register_ill_book_request_from_borrower_page(req, borrower_id, ln=CFG_SITE_LANG): """ Display a form where is possible to searh for an item. """ navtrail_previous_links = 'Admin Area' \ ' > Circulation Management' \ ' ' % (CFG_SITE_URL, CFG_SITE_URL) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) infos = [] body = bibcirculation_templates.tmpl_register_ill_book_request_from_borrower_page(infos=infos, borrower_id=borrower_id, ln=ln) return page(title="Register ILL Book request", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def register_ill_book_request_from_borrower_page_result(req, borrower_id, p, f, ln=CFG_SITE_LANG): """ Search an item and return a list with all the possible results. To retrieve the information desired, we use the method 'perform_request_search' (from search_engine.py). In the case of BibCirculation, we are just looking for books (items) inside the collection 'Books'. @type p: string @param p: search pattern @type f: string @param f: search field @return: list of recids """ if f == 'barcode': has_recid = db.get_recid(p) infos = [] if has_recid is None: infos.append('The barcode %s does not exist on BibCirculation database.' % p) body = bibcirculation_templates.tmpl_register_ill_book_request_from_borrower_page(infos=infos, ln=ln) else: body = bibcirculation_templates.tmpl_register_ill_book_request_from_borrower_page_result(result=has_recid, borrower_id=borrower_id, ln=ln) else: result = perform_request_search(cc="Books", sc="1", p=p, f=f) if len(result) == 0: return register_ill_request_from_borrower_page_step1(req, borrower_id, ln) else: body = bibcirculation_templates.tmpl_register_ill_book_request_from_borrower_page_result(result=result, borrower_id=borrower_id, ln=ln) navtrail_previous_links = 'Admin Area' \ ' > Circulation Management' \ ' ' % (CFG_SITE_URL, CFG_SITE_URL) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) return page(title="Register ILL Book request", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def register_ill_request_from_borrower_page_step1(req, borrower_id, ln=CFG_SITE_LANG): """ """ infos = [] navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_register_ill_request_from_borrower_page_step1(infos=infos, borrower_id=borrower_id, ln=ln) return page(title="Register ILL request", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def register_ill_request_from_borrower_page_step2(req, borrower_id, title, authors, place, publisher, year, edition, isbn, period_of_interest_from, period_of_interest_to, additional_comments, only_edition, ln=CFG_SITE_LANG): """ """ infos = [] if validate_date_format(period_of_interest_from) is False: infos.append("The given 'period_of_interest_from' %s" \ " is not a valid date or date format" % period_of_interest_from) body = bibcirculation_templates.tmpl_register_ill_request_from_borrower_page_step1(infos=infos, borrower_id=borrower_id, ln=ln) elif validate_date_format(period_of_interest_to) is False: infos.append("The given 'period_of_interest_to' %s" \ " is not a valid date or date format" % period_of_interest_to) body = bibcirculation_templates.tmpl_register_ill_request_from_borrower_page_step1(infos=infos, borrower_id=borrower_id, ln=ln) else: book_info = (title, authors, place, publisher, year, edition, isbn) user_info = db.get_borrower_details(borrower_id) request_details = (period_of_interest_from, period_of_interest_to, additional_comments, only_edition) body = bibcirculation_templates.tmpl_register_ill_request_with_no_recid_step3(book_info=book_info, user_info=user_info, request_details=request_details, ln=ln) navtrail_previous_links = 'Admin Area' \ ' > Circulation Management' \ ' ' % (CFG_SITE_URL, CFG_SITE_URL) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) return page(title="Register ILL request", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def register_ill_article_request_step1(req, ln=CFG_SITE_LANG): """ """ infos = [] navtrail_previous_links = 'Admin Area' \ ' > Circulation Management' \ ' ' % (CFG_SITE_URL, CFG_SITE_URL) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_register_ill_article_request_step1(infos=infos, ln=ln) return page(title="Register ILL Article request", uid=id_user, req=req, body=body, metaheaderadd = ""%(CFG_SITE_URL), navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def register_ill_article_request_step2(req, periodical_title, article_title, author, report_number, volume, issue, pages, year, issn, period_of_interest_from, period_of_interest_to, additional_comments, key, string, ln=CFG_SITE_LANG): infos = [] if key and not string: infos.append('Empty string. Please, try again.') article_info = (periodical_title, article_title, author, report_number, volume, issue, pages, year, issn) request_details = (period_of_interest_from, period_of_interest_to, additional_comments) body = bibcirculation_templates.tmpl_register_ill_article_request_step2(article_info=article_info, request_details=request_details, result=None, key=key, string=string, infos=infos, ln=ln) navtrail_previous_links = 'Admin Area' \ ' > Circulation Management' \ ' ' % (CFG_SITE_URL, CFG_SITE_URL) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) return page(title="Register ILL request", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) list_infos = [] if CFG_CERN_SITE == 1: if key =='ccid' and string: result = db.get_borrower_data_by_id(string) ###if result == from invenio.bibcirculation_cern_ldap import get_user_info_from_ldap result = get_user_info_from_ldap(ccid=string) try: name = result['cn'][0] except: name = "" try: ccid = result['employeeID'][0] except: ccid = "" try: email = result['mail'][0] except: email = "" try: phone = result['telephoneNumber'][0] except: phone = "" try: address = result['physicalDeliveryOfficeName'][0] except: address = "" try: mailbox = result['postOfficeBox'][0] except: mailbox = "" tup = (ccid, name, email, phone, address, mailbox) list_infos.append(tup) elif key =='name' and string: result = db.get_borrower_data_by_name(string) for (borrower_id, ccid, name, email, phone, address, mailbox) in result: tup = (borrower_id, ccid, name, email, phone, address, mailbox) list_infos.append(tup) elif key =='email' and string: result = db.get_borrower_data_by_email(string) for (borrower_id, ccid, name, email, phone, address, mailbox) in result: tup = (borrower_id, ccid, name, email, phone, address, mailbox) list_infos.append(tup) else: result = list_infos else: if key =='name' and string: result = db.get_borrower_data_by_name(string) elif key =='email' and string: result = db.get_borrower_data_by_email(string) else: result = db.get_borrower_data_by_id(string) for (borrower_id, ccid, name, email, phone, address, mailbox) in result: tup = (borrower_id, ccid, name, email, phone, address, mailbox) list_infos.append(tup) if validate_date_format(period_of_interest_from) is False: infos = [] infos.append("The given 'period_of_interest_from' %s" \ " is not a valid date or date format" % period_of_interest_from) body = bibcirculation_templates.tmpl_register_ill_article_request_step1(infos=infos, ln=ln) elif validate_date_format(period_of_interest_to) is False: infos = [] infos.append("The given 'period_of_interest_to' %s" \ " is not a valid date or date format" % period_of_interest_to) body = bibcirculation_templates.tmpl_register_ill_article_request_step1(infos=infos, ln=ln) else: article_info = (periodical_title, article_title, author, report_number, volume, issue, pages, year, issn) request_details = (period_of_interest_from, period_of_interest_to, additional_comments) body = bibcirculation_templates.tmpl_register_ill_article_request_step2(article_info=article_info, request_details=request_details, result=list_infos, key=key, string=string, infos=infos, ln=ln) navtrail_previous_links = 'Admin Area' \ ' > Circulation Management' \ ' ' % (CFG_SITE_URL, CFG_SITE_URL) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) return invenio.webpage.page(title="Register ILL request", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def register_ill_article_request_step3(req, item_info, user_info, request_details, ln): """ """ #id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) (periodical_title, title, authors, _report_number, volume, issue, page_number, year, issn) = item_info volume = volume + ', '+ issue + ', '+ page_number info = (title, authors, "", "", year, "", issn) create_ill_record(info) item_info = {'periodical_title': periodical_title, 'title': title, 'authors': authors, 'place': "", 'publisher': "", 'year' : year, 'edition': "", 'issn' : issn, 'volume': volume } (period_of_interest_from, period_of_interest_to, library_notes) = request_details only_edition = "" (borrower_id, ccid, _name, _email, _phone, _address, _mailbox) = user_info ill_request_notes = {} if library_notes: ill_request_notes[time.strftime("%Y-%m-%d %H:%M:%S")] = str(library_notes) db.ill_register_request_on_desk(borrower_id, item_info, period_of_interest_from, period_of_interest_to, 'new', str(ill_request_notes), only_edition, 'article') #navtrail_previous_links = 'Admin Area' \ # '' % (CFG_SITE_URL,) return list_ill_request(req, 'new', ln) def ill_search(req, ln=CFG_SITE_LANG): """ """ infos = [] navtrail_previous_links = 'Admin Area' \ ' > Circulation Management' \ ' ' % (CFG_SITE_URL, CFG_SITE_URL) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) body = bibcirculation_templates.tmpl_ill_search(infos=infos, ln=ln) return page(title="ILL search", uid=id_user, req=req, body=body, metaheaderadd = "" % CFG_SITE_URL, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def ill_search_result(req, p, f, date_from, date_to, ln): """ Search an item and return a list with all the possible results. To retrieve the information desired, we use the method 'perform_request_search' (from search_engine.py). In the case of BibCirculation, we are just looking for books (items) inside the collection 'Books'. @type p: string @param p: search pattern @type f: string @param f: search field @return: list of recids """ navtrail_previous_links = 'Admin Area' \ ' > Circulation Management' \ ' ' % (CFG_SITE_URL, CFG_SITE_URL) if date_from == 'the beginning': date_from = '0000-00-00' if date_to == 'now': date_to = '9999-12-31' if f=='title': ill_req = db.search_ill_requests_title(p, date_from, date_to) elif f=='ILL_request_ID': ill_req = db.search_ill_requests_id(p, date_from, date_to) body = bibcirculation_templates.tmpl_list_ill_request(ill_req=ill_req, ln=ln) return page(title="List of ILL requests", req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) #if f == 'title': #from invenio.intbitset import intbitset # #ill_cds = get_list_of_ILL_requests() #ill_books = perform_request_search(cc="ILL Books") # #tmp = intbitset(ill_cds + ill_books) #ill_pattern = intbitset(perform_request_search(c=["Books", "ILL Books"], p=p)) # #result = list(ill_pattern & tmp) def delete_copy_step1(req, barcode, ln): infos = [] navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) - + recid = db.get_recid(barcode) if recid: recid = recid[0] infos.append("Do you really want to delete this copy of the book?") copies = db.get_item_copies_details(recid) requests = db.get_item_requests(recid) loans = db.get_item_loans(recid) req_hist_overview = db.get_item_requests_historical_overview(recid) loans_hist_overview = db.get_item_loans_historical_overview(recid) id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) title="Delete copy" body = bibcirculation_templates.tmpl_delete_copy_step1(barcode_to_delete=barcode, recid=recid, result=copies, infos=infos, ln=ln) else: message = """The barcode %s was not found"""%(barcode) infos.append(message) title="Item search" body = bibcirculation_templates.tmpl_item_search(infos=infos, ln=ln) return page(title=title, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def delete_copy_step2(req, barcode, ln): id_user = getUid(req) (auth_code, auth_message) = is_adminuser(req) if auth_code != 0: return mustloginpage(req, auth_message) infos = [] recid = db.get_recid(barcode) if recid: recid = recid[0] if db.delete_copy(barcode)==1: message = """The copy with barcode %s has been deleted."""%(barcode) else: message = """It was NOT possible to delete the copy with barcode %s"""%(barcode) infos.append(message) copies = db.get_item_copies_details(recid) requests = db.get_item_requests(recid) loans = db.get_item_loans(recid) req_hist_overview = db.get_item_requests_historical_overview(recid) loans_hist_overview = db.get_item_loans_historical_overview(recid) title="Item details" body = bibcirculation_templates.tmpl_get_item_details(recid=recid, copies=copies, requests=requests, loans=loans, req_hist_overview = req_hist_overview, loans_hist_overview = loans_hist_overview, infos=infos, ln=ln) else: message = """The barcode %s was not found"""%(barcode) infos.append(message) title="Item search" body = bibcirculation_templates.tmpl_item_search(infos=infos, ln=ln) navtrail_previous_links = 'Admin Area' \ '' % (CFG_SITE_URL,) return page(title=title, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) \ No newline at end of file