diff --git a/modules/bibcirculation/lib/bibcirculation.py b/modules/bibcirculation/lib/bibcirculation.py index dfaf97f25..ea72d4d03 100644 --- a/modules/bibcirculation/lib/bibcirculation.py +++ b/modules/bibcirculation/lib/bibcirculation.py @@ -1,695 +1,698 @@ # -*- 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 + make_copy_available, \ + create_ill_record from invenio.bibcirculation_cern_ldap import get_user_info_from_ldap from invenio.bibcirculation_config import CFG_BIBCIRCULATION_LIBRARIAN_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(uid, recid, barcode, ln=CFG_SITE_LANG): +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(uid=uid, - recid=recid, + body = bibcirculation_templates.tmpl_new_request2(recid=recid, barcode=barcode, ln=ln) return body def perform_new_request_send(uid, recid, from_year, from_month, from_day, to_year, to_month, to_day, barcode, ln=CFG_SITE_LANG): """ @param recid: recID - CDS Invenio record identifier @param ln: language of the page """ request_from = get_datetext(from_year, from_month, from_day) request_to = get_datetext(to_year, to_month, to_day) nb_requests = db.get_number_requests_per_copy(barcode) is_on_loan = db.is_item_on_loan(barcode) if nb_requests == 0 and is_on_loan is not None: status = 'waiting' elif nb_requests == 0 and is_on_loan is None: status = 'pending' else: status = 'waiting' user = collect_user_info(uid) is_borrower = db.is_borrower(user['email']) if is_borrower != 0: address = db.get_borrower_address(user['email']) if address != 0: db.new_hold_request(is_borrower, recid, barcode, request_from, request_to, status) db.update_item_status('requested', barcode) send_email(fromaddr=CFG_BIBCIRCULATION_LIBRARIAN_EMAIL, toaddr=CFG_SITE_SUPPORT_EMAIL, subject='Hold request for books confirmation', content=hold_request_mail(recid, is_borrower), attempt_times=1, attempt_sleeptime=10 ) if CFG_CERN_SITE == 1: message = bibcirculation_templates.tmpl_message_request_send_ok_cern(ln=ln) else: message = bibcirculation_templates.tmpl_message_request_send_ok_other(ln=ln) else: if CFG_CERN_SITE == 1: - result = get_user_info_from_ldap(email=user['email']) + email=user['email'] + result = get_user_info_from_ldap(email) try: ldap_address = result['physicalDeliveryOfficeName'][0] except KeyError: ldap_address = None if ldap_address is not None: db.add_borrower_address(ldap_address, email) db.new_hold_request(is_borrower, recid, barcode, request_from, request_to, status) db.update_item_status('requested', barcode) send_email(fromaddr=CFG_BIBCIRCULATION_LIBRARIAN_EMAIL, toaddr=CFG_SITE_SUPPORT_EMAIL, subject='Hold request for books confirmation', content=hold_request_mail(recid, is_borrower), attempt_times=1, attempt_sleeptime=10 ) message = bibcirculation_templates.tmpl_message_request_send_ok_cern(ln=ln) else: message = bibcirculation_templates.tmpl_message_request_send_fail_cern(ln=ln) else: message = bibcirculation_templates.tmpl_message_request_send_fail_other(ln=ln) else: if CFG_CERN_SITE == 1: result = get_user_info_from_ldap(email=user['email']) try: name = result['cn'][0] except KeyError: name = None try: email = result['mail'][0] except KeyError: email = None try: phone = result['telephoneNumber'][0] except KeyError: phone = None try: address = result['physicalDeliveryOfficeName'][0] except KeyError: address = None try: mailbox = result['postOfficeBox'][0] except KeyError: mailbox = None if address is not None: db.new_borrower(name, email, phone, address, mailbox, '') is_borrower = db.is_borrower(email) db.new_hold_request(is_borrower, recid, barcode, request_from, request_to, status) db.update_item_status('requested', barcode) send_email(fromaddr=CFG_BIBCIRCULATION_LIBRARIAN_EMAIL, toaddr=CFG_SITE_SUPPORT_EMAIL, subject='Hold request for books confirmation', content=hold_request_mail(recid, is_borrower), attempt_times=1, attempt_sleeptime=10 ) message = bibcirculation_templates.tmpl_message_request_send_ok_cern(ln=ln) else: message = bibcirculation_templates.tmpl_message_request_send_fail_cern(ln=ln) else: message = bibcirculation_templates.tmpl_message_request_send_ok_other(ln=ln) body = bibcirculation_templates.tmpl_new_request_send(message=message, ln=ln) return body -def ill_request_with_recid(recid, uid, ln=CFG_SITE_LANG): +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 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']) #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, 'pending', additional_comments, only_edition or 'False') #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, subject='ILL request for books confirmation', content=hold_request_mail(recid, is_borrower), 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_ill_request_with_recid(recid, infos=infos, ln=ln) #Borrower doesn't have an address. else: #If BibCirculation at CERN, use LDAP. if CFG_CERN_SITE == 1: - result = get_user_info_from_ldap(email=user['email']) + 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, additional_comments, conditions, only_edition or 'False') 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, subject='ILL request for books confirmation', content=hold_request_mail(recid, is_borrower), 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 # verify address if address is not None: db.new_borrower(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, additional_comments, conditions, only_edition or 'False') 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, subject='ILL request for books confirmation', content=hold_request_mail(recid, is_borrower), 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 -def display_ill_form(uid, ln=CFG_SITE_LANG): +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, 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, 'pending', additional_comments, only_edition or 'False') #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, 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: - result = get_user_info_from_ldap(email=user['email']) + 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, 'pending', additional_comments, only_edition or 'False') 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, 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 # verify address if address is not None: db.new_borrower(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, 'pending', additional_comments, only_edition or 'False') 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, 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_daemon.py b/modules/bibcirculation/lib/bibcirculation_daemon.py index 1b07f9d51..b3b6ad161 100644 --- a/modules/bibcirculation/lib/bibcirculation_daemon.py +++ b/modules/bibcirculation/lib/bibcirculation_daemon.py @@ -1,192 +1,190 @@ # -*- 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, write_message +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() """) 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 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 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 send_second_recall(date_letters): content = generate_email_body(CFG_BIBCIRCULATION_TEMPLATES['RECALL2'], loan_id) elif number_of_letters == 2 and send_third_recall(date_letters): content = generate_email_body(CFG_BIBCIRCULATION_TEMPLATES['RECALL3'], loan_id) else: content = generate_email_body(CFG_BIBCIRCULATION_TEMPLATES['RECALL3'], loan_id) title = ''.join(get_fieldvalues(recid, "245__a")) subject = "LOAN RECALL: " + title - update_expired_loan(id_loan) + 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!!") 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_dblayer.py b/modules/bibcirculation/lib/bibcirculation_dblayer.py index 5eede9b82..48c4bfd60 100644 --- a/modules/bibcirculation/lib/bibcirculation_dblayer.py +++ b/modules/bibcirculation/lib/bibcirculation_dblayer.py @@ -1,2829 +1,2829 @@ # -*- 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. """Every db-related function of module bibcirculation""" __revision__ = "$Id$" from invenio.dbquery import run_sql def verify_office_reference(uid): """ Verify is there a reference for user's office @param uid: user ID """ query = """SELECT office FROM crcborrower WHERE id=%(user_id)i """ uid = int(uid) res = run_sql(query%uid) return res def get_holdings_info(recid): """ Get information about holding, using recid. @param recid: identify the record. Primary key of bibrec. @type recid: int @return holdings information """ res = run_sql(""" select count(lr.id_bibrec), it.loan_period, DATE_FORMAT(max(lr.period_of_interest_to),'%%Y-%%m-%%d'), lib.name from crcLOANREQUEST lr, crcITEM it, crcLIBRARY lib where lib.id = it.id_crcLIBRARY and lr.id_bibrec=it.id_bibrec and it.id_bibrec=%s and lr.status = 'waiting' GROUP BY (lr.id_bibrec) """, (recid, )) return res def get_holdings_information(recid): """ Get information about holding, using recid. @param recid: identify the record. Primary key of bibrec. @type recid: int @return holdings information """ res = run_sql("""select it.barcode, lib.name, it.collection, it.location, it.description, it.loan_period, it.status, DATE_FORMAT(ln.due_date, '%%Y-%%m-%%d') from crcITEM it left join crcLOAN ln on it.barcode = ln.barcode and ln.status != 'returned' left join crcLIBRARY lib on lib.id = it.id_crcLIBRARY where it.id_bibrec=%s""", (recid, )) return res def get_holdings_details(recid): """ Get details about holdings (loan period, location and library). @param recid: identify the record. Primary key of bibrec. @type recid: int @return list with loan period, location and library. """ res = run_sql(""" select it.loan_period, lib.name, it.location from crcITEM it, crcLIBRARY lib where id_bibrec=%s limit 1""", (recid, )) return res def get_loan_details(recid): """ Get details about a loan (barcode and status). @param recid: identify the record. Primary key of bibrec. @type recid: int @return loan details """ res = run_sql("""select barcode, status from crcITEM where id_bibrec=%s and status = "available" limit 1; """, (recid, )) return res def get_due_date_loan(recid): """ Get the due date of a loan. @param recid: identify the record. Primary key of bibrec. @type recid: int @return due date """ res = run_sql("""select DATE_FORMAT(max(due_date),'%%Y-%%m-%%d') from crcLOAN where id_bibrec=%s and status != 'returned' """, (recid, )) if res: return res[0][0] else: return None def get_holdings_info_no_requests(recid): """ @param recid: identify the record. Primary key bibrec. @type recid: int """ res = run_sql(""" select it.loan_period, lib.name from crcITEM it, crcLIBRARY lib where it.id_crcLIBRARY=lib.id and it.id_bibrec=%s """, (recid, )) return res def get_request_recid(request_id): """ Get recid of a given request_id @param request_id: identify the (hold) request. Primary key of crcLOANREQUEST. @type request_id: int @return recid """ res = run_sql(""" select id_bibrec from crcLOANREQUEST where id=%s """, (request_id, )) if res: return res[0][0] else: return None def get_request_borrower_id(request_id): """ Get borrower_id of a given request_id @param request_id: identify the (hold) request. Primary key of crcLOANREQUEST. @type request_id: int @return borrower_id """ res = run_sql(""" select id_crcBORROWER from crcLOANREQUEST where id=%s """, (request_id, )) if res: return res[0][0] else: return None def get_request_barcode(request_id): """ Get the barcode associate to a request_id. @param request_id: identify the (hold) request. Primary key of crcLOANREQUEST. @type request_id: int @return barcode """ res = run_sql(""" select barcode from crcLOANREQUEST where id=%s """, (request_id, )) if res: return res[0][0] else: return None def get_id_bibrec(barcode): """ Get the id bibrec (or recid). @param barcode: identify the item. Primary key of crcITEM. @type barcode: string @return recid or None """ res = run_sql("""select id_bibrec from crcITEM where barcode=%s """, (barcode, )) if res: return res[0][0] else: return None def update_item_status(status, barcode): """ Update the status of an item (using the barcode). @param status: status of the item. @type status: string @param barcode: identify the item. Primary key of crcITEM. @type barcode: string @return """ if status == 'on loan': return int(run_sql("""UPDATE crcITEM SET status=%s, number_of_requests = number_of_requests + 1 WHERE barcode=%s""", (status, barcode))) else: return int(run_sql("""UPDATE crcITEM SET status=%s WHERE barcode=%s""", (status, barcode))) def new_hold_request(borrower_id, recid, barcode, date_from, date_to, status): """ Create a new hold request. @param borrower_id: identify the borrower. Primary key of crcBORROWER. @type borrower_id: 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 @param date_from: begining of the period of interest. @type date_from: string @param date_to: end of the period of interest. @type date_to: string @param status: hold request status. @type status: string @return """ res = run_sql("""INSERT INTO crcLOANREQUEST(id_crcBORROWER, id_bibrec, barcode, period_of_interest_from, period_of_interest_to, status, request_date) VALUES (%s, %s, %s, %s, %s, %s, NOW()) """, (borrower_id, recid, barcode, date_from, date_to, status)) return res def get_barcode(recid): """ Get all the barcodes(copies) of a record(item). @param recid: identify the record. Primary key of bibrec. @type recid: int @return list with barcode(s). """ res = run_sql("""select barcode from crcITEM where id_bibrec=%s """, (recid, )) if res: return res[0][0] else: return None def get_due_date(barcode): """ Get the due date of a given barcode. @param barcode: identify the item. Primary key of crcITEM. @type barcode: string @return due_date """ res = run_sql("""select period_of_interest_to from crcLOANREQUEST where barcode=%s """, (barcode, )) if res: return res[0][0] else: return None def get_number_requests(recid): """ Get the number of requests of a record. @param recid: identify the record. Primary key of bibrec. @type recid: int @return number of request (int) """ res = run_sql(""" select id_bibrec from crcLOANREQUEST where id_bibrec=%s and status != 'done' and status != 'cancelled'; """, (recid, )) return res def get_number_requests2(barcode, request_id): """ @param barcode: identify the item. Primary key of crcITEM. @type barcode: string @param request_id: identify the (hold) request. Primary key of crcLOANREQUEST. @type request_id: int """ res = run_sql("""select id_bibrec from crcLOANREQUEST where id < %s and barcode=%s and status != 'done' """, (request_id, barcode)) return res def loan_return_confirm(borrower_id, recid): """ @param borrower_id: identify the borrower. Primary key of crcBORROWER. @type borrower_id: int @param recid: identify the record. Primary key of bibrec. @type recid: int """ res = run_sql("""select bor.name, it.id_bibrec from crcBORROWER bor, crcITEM it where bor.id=%s and it.id_bibrec=%s """, (borrower_id, recid)) return res def get_borrower_id(barcode): """ Get the borrower id who is associate to a loan. @param barcode: identify the item. Primary key of crcITEM. @type barcode: string @return borrower_id or None """ res = run_sql(""" select id_crcBORROWER from crcLOAN where barcode=%s and (status='on loan' or status='expired')""", (barcode, )) try: return res[0][0] except IndexError: return None def get_borrower_email(borrower_id): """ Get the email of a borrower. @param borrower_id: identify the borrower. Primary key of crcBORROWER. @type borrower_id: int @return borrower's email (string). """ res = run_sql("""select email from crcBORROWER where id=%s""", (borrower_id, )) if res: return res[0][0] else: return None def get_next_waiting_loan_request(recid): """ Get the next waiting (loan) request for a given recid. @param recid: identify the record. Primary key of bibrec. @type recid: int @return list with request_id, borrower_name, recid, status, period_of_interest (from and to) and request_date. """ res = run_sql("""SELECT lr.id, bor.name, lr.id_bibrec, lr.status, DATE_FORMAT(lr.period_of_interest_from,'%%Y-%%m-%%d'), DATE_FORMAT(lr.period_of_interest_to,'%%Y-%%m-%%d'), lr.request_date FROM crcLOANREQUEST lr, crcBORROWER bor WHERE lr.id_crcBORROWER=bor.id AND (lr.status='waiting' OR lr.status='pending') AND lr.id_bibrec=%s ORDER BY lr.request_date""", (recid, )) return res def update_loan_info(returned_on, status, barcode): """ Update loan information when copy is returned. @param returned_on: return date. @type returned_on: string @param status: new loan status. @type status: string @param barcode: identify the item. Primary key of crcITEM. @type barcode: string @return """ return int(run_sql("""update crcLOAN set returned_on=%s, status=%s where barcode=%s """, (returned_on, status, barcode))) def get_item_copies_details(recid): """ Get copies details of a given recid. @param recid: identify the record. Primary key of bibrec. @type recid: int @return list with barcode, loan_period, library_name, library_id, location, number_of_requests, status, collection, description and due_date. """ res = run_sql("""select it.barcode, it.loan_period, lib.name, lib.id, it.location, it.number_of_requests, it.status, it.collection, it.description, DATE_FORMAT(ln.due_date,'%%Y-%%m-%%d') from crcITEM it left join crcLOAN ln on it.barcode = ln.barcode and ln.status != 'returned' left join crcLIBRARY lib on lib.id = it.id_crcLIBRARY where it.id_bibrec=%s order by it.creation_date """, (recid, )) return res def get_number_copies(recid): """ Get the number of copies of a given recid. @param recid: identify the record. Primary key of bibrec. @type recid: int @return number_of_copies """ res = run_sql("""select count(barcode) from crcITEM where id_bibrec=%s """, (recid, )) return res[0][0] def bor_loans_historical_overview(borrower_id): """ Get loans historical overview of a given borrower_id. @param borrower_id: identify the borrower. Primary key of crcBORROWER. @type borrower_id: int @return list with loans historical overview. """ res = run_sql(""" select l.id_bibrec, l.barcode, lib.name, it.location, DATE_FORMAT(l.loaned_on,'%%Y-%%m-%%d'), DATE_FORMAT(l.due_date,'%%Y-%%m-%%d'), l.returned_on, l.number_of_renewals, l.overdue_letter_number from crcLOAN l, crcITEM it, crcLIBRARY lib where l.id_crcBORROWER=%s and lib.id = it.id_crcLIBRARY and it.barcode = l.barcode and l.status = 'returned' """, (borrower_id, )) return res def bor_requests_historical_overview(borrower_id): """ Get requests historical overview of a given borrower_id. @param borrower_id: identify the borrower. Primary key of crcBORROWER. @type borrower_id: int @return list with requests historical overview. """ res = run_sql("""select lr.id_bibrec, lr.barcode, lib.name, it.location, DATE_FORMAT(lr.period_of_interest_from,'%%Y-%%m-%%d'), DATE_FORMAT(lr.period_of_interest_to,'%%Y-%%m-%%d'), lr.request_date from crcLOANREQUEST lr, crcITEM it, crcLIBRARY lib where lr.id_crcBORROWER=%s and lib.id = it.id_crcLIBRARY and it.barcode = lr.barcode and lr.status ='done' """ , (borrower_id, )) return res def get_item_loans_historical_overview(recid): """ @param recid: identify the record. Primary key of bibrec. @type recid: int """ res = run_sql("""select bor.name, bor.id, l.barcode, lib.name, it.location, DATE_FORMAT(l.loaned_on,'%%Y-%%m-%%d'), DATE_FORMAT(l.due_date,'%%Y-%%m-%%d'), l.returned_on, l.number_of_renewals, l.overdue_letter_number from crcLOAN l, crcBORROWER bor, crcITEM it, crcLIBRARY lib where l.id_crcBORROWER=bor.id and lib.id = it.id_crcLIBRARY and it.barcode = l.barcode and l.id_bibrec = %s and l.status = 'returned' """ , (recid, )) return res def get_item_requests_historical_overview(recid): """ recid: identify the record. It is also the primary key of the table bibrec. """ res = run_sql(""" select bor.name, bor.id, lr.barcode, lib.name, it.location, DATE_FORMAT(lr.period_of_interest_from,'%%Y-%%m-%%d'), DATE_FORMAT(lr.period_of_interest_to,'%%Y-%%m-%%d'), lr.request_date from crcLOANREQUEST lr, crcBORROWER bor, crcITEM it, crcLIBRARY lib where lr.id_crcBORROWER=bor.id and lib.id = it.id_crcLIBRARY and it.barcode = lr.barcode and lr.id_bibrec = %s and lr.status = 'done' """, (recid, )) return res def get_library_details(library_id): """ library_id: identify the library. It is also the primary key of the table crcLIBRARY. """ res = run_sql("""select id, name, address, email, phone, notes from crcLIBRARY where id=%s; """, (library_id, )) if res: return res[0] else: return None def get_loan_request_by_status(status): """ status: request status. """ res = run_sql("""SELECT DISTINCT lr.id, lr.id_bibrec, bor.name, bor.id, lib.name, it.location, DATE_FORMAT(lr.period_of_interest_from,'%%Y-%%m-%%d'), DATE_FORMAT(lr.period_of_interest_to,'%%Y-%%m-%%d'), lr.request_date FROM crcLOANREQUEST lr, crcBORROWER bor, crcITEM it, crcLIBRARY lib WHERE lr.id_crcBORROWER=bor.id AND it.barcode=lr.barcode AND lib.id = it.id_crcLIBRARY AND lr.status=%s ORDER BY lr.request_date; """ , (status, )) return res def update_loan_request_status(request_id, status): """ request_id: identify the hold request. It is also the primary key of the table crcLOANREQUEST. status: new request status. """ return int(run_sql("""UPDATE crcLOANREQUEST SET status=%s WHERE id=%s""", (status, request_id))) def get_all_requests(): """ Retrieve all requests. """ res = run_sql("""SELECT lr.id, bor.id, bor.name, lr.id_bibrec, lr.status, DATE_FORMAT(lr.period_of_interest_from,'%Y-%m-%d'), DATE_FORMAT(lr.period_of_interest_to,'%Y-%m-%d'), lr.request_date FROM crcLOANREQUEST lr, crcBORROWER bor WHERE bor.id = lr.id_crcBORROWER and (lr.status='waiting' or lr.status='pending') ORDER BY lr.request_date """) return res def get_item_requests(recid): """ recid: identify the record. It is also the primary key of the table bibrec. """ res = run_sql("""SELECT bor.id, bor.name, lr.id_bibrec, lr.status, lib.name, it.location, DATE_FORMAT(lr.period_of_interest_from,'%%Y-%%m-%%d'), DATE_FORMAT(lr.period_of_interest_to,'%%Y-%%m-%%d'), lr.id, lr.request_date FROM crcLOANREQUEST lr, crcBORROWER bor, crcITEM it, crcLIBRARY lib WHERE bor.id = lr.id_crcBORROWER and lr.id_bibrec=%s and lr.status!='done' and lr.status!='cancelled' and lr.barcode = it.barcode and lib.id = it.id_crcLIBRARY """, (recid, )) return res def get_all_requests_for_item_order_by_status(recid): """ recid: identify the record. It is also the primary key of the table bibrec. """ res = run_sql("""SELECT bor.id, bor.name, lr.id_bibrec, lr.status, DATE_FORMAT(lr.period_of_interest_from,'%%Y-%%m-%%d'), DATE_FORMAT(lr.period_of_interest_to,'%%Y-%%m-%%d') FROM crcLOANREQUEST lr, crcBORROWER bor WHERE bor.id = lr.id_crcBORROWER and lr.id_bibrec=%s and lr.status!='done' ORDER BY status """, (recid, )) return res def get_all_requests_for_item_order_by_name(recid): """ recid: identify the record. It is also the primary key of the table bibrec. """ res = run_sql("""SELECT bor.id, bor.name, lr.id_bibrec, lr.status, DATE_FORMAT(lr.period_of_interest_from,'%%Y-%%m-%%d'), DATE_FORMAT(lr.period_of_interest_to,'%%Y-%%m-%%d') FROM crcLOANREQUEST lr, crcBORROWER bor WHERE bor.id = lr.id_crcBORROWER and lr.id_bibrec=%s and lr.status!='done' ORDER BY name """, (recid, )) return res def get_all_requests_order_by_status(): """ Get all requests order by status. """ res = run_sql("""SELECT bor.id, bor.name, lr.id_bibrec, lr.status, DATE_FORMAT(lr.period_of_interest_from,'%Y-%m-%d'), DATE_FORMAT(lr.period_of_interest_to,'%Y-%m-%d') FROM crcLOANREQUEST lr, crcBORROWER bor WHERE bor.id = lr.id_crcBORROWER and lr.status!='done' ORDER BY status """) return res def get_all_requests_order_by_name(): """ Get all requests order by name. """ res = run_sql("""SELECT bor.id, bor.name, lr.id_bibrec, lr.status, DATE_FORMAT(lr.period_of_interest_from,'%Y-%m-%d'), DATE_FORMAT(lr.period_of_interest_to,'%Y-%m-%d') FROM crcLOANREQUEST lr, crcBORROWER bor WHERE bor.id = lr.id_crcBORROWER and lr.status!='done' ORDER BY name """) return res def get_all_requests_order_by_item(): """ Get all requests order by item. """ res = run_sql("""SELECT bor.id, bor.name, lr.id_bibrec, lr.status, DATE_FORMAT(lr.period_of_interest_from,'%Y-%m-%d'), DATE_FORMAT(lr.period_of_interest_to,'%Y-%m-%d') FROM crcLOANREQUEST lr, crcBORROWER bor WHERE bor.id = lr.id_crcBORROWER and lr.status!='done' ORDER BY id_bibrec """) return res def get_borrower_details(borrower_id): """ borrower_id: identify the borrower. It is also the primary key of the table crcBORROWER. """ res = run_sql("""select id, name, email, phone, address, mailbox from crcBORROWER where id=%s""", (borrower_id, )) if res: return res[0] else: return None def get_borrower_name(borrower_id): """ borrower_id: identify the borrower. It is also the primary key of the table crcBORROWER. """ res = run_sql("""select name from crcBORROWER where id=%s""", (borrower_id, )) if res: return res[0][0] else: return None def loan_on_desk_confirm(barcode, borrower_id): """ 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. """ res = run_sql("""select it.id_bibrec, bor.name from crcITEM it, crcBORROWER bor where it.barcode=%s and bor.id=%s """, (barcode, borrower_id)) return res def search_borrower_by_name(string): """ string: search pattern. """ res = run_sql("""select id, name from crcBORROWER where name regexp %s order by name """, (string, )) return res def search_borrower_by_email(string): """ string: search pattern. """ res = run_sql("""select id, name from crcBORROWER where email regexp %s """, (string, )) return res def search_borrower_by_phone(string): """ string: search pattern. """ res = run_sql("""select id, name from crcBORROWER where phone regexp %s """, (string, )) return res def search_borrower_by_id(string): """ string: search pattern. """ res = run_sql("""select id, name from crcBORROWER where id=%s """, (string, )) return res def search_user_by_email(string): """ string: search pattern. """ res = run_sql(""" select id, email from user where email regexp %s """, (string, )) return res def get_borrower_loan_details(borrower_id): """ borrower_id: identify the borrower. It is also the primary key of the table crcBORROWER. """ res = run_sql(""" select it.id_bibrec, l.barcode, DATE_FORMAT(l.loaned_on,'%%Y-%%m-%%d'), DATE_FORMAT(l.due_date,'%%Y-%%m-%%d'), l.number_of_renewals, l.overdue_letter_number, DATE_FORMAT(l.overdue_letter_date,'%%Y-%%m-%%d'), l.type, l.notes, l.id, l.status from crcLOAN l, crcITEM it where l.barcode=it.barcode and id_crcBORROWER=%s and l.status!='returned' """, (borrower_id, )) return res def get_borrower_request_details(borrower_id): """ borrower_id: identify the borrower. It is also the primary key of the table crcBORROWER. """ res = run_sql("""SELECT lr.id_bibrec, lr.status, lib.name, it.location, DATE_FORMAT(lr.period_of_interest_from,'%%Y-%%m-%%d'), DATE_FORMAT(lr.period_of_interest_to,'%%Y-%%m-%%d'), lr.request_date, lr.id FROM crcLOANREQUEST lr, crcITEM it, crcLIBRARY lib WHERE lr.id_crcBORROWER =%s and (lr.status='waiting' or lr.status='pending') and lib.id = it.id_crcLIBRARY and lr.barcode = it.barcode """, (borrower_id, )) return res def get_borrower_request_details_order_by_item(borrower_id): """ borrower_id: identify the borrower. It is also the primary key of the table crcBORROWER. """ res = run_sql("""SELECT lr.id_crcBORROWER, lr.id_bibrec, lr.status, DATE_FORMAT(lr.period_of_interest_from,'%%Y-%%m-%%d'), DATE_FORMAT(lr.period_of_interest_to,'%%Y-%%m-%%d') FROM crcLOANREQUEST lr WHERE lr.id_crcBORROWER =%s and lr.status!='done' ORDER BY id_bibrec """, (borrower_id, )) return res def get_borrower_request_details_order_by_status(borrower_id): """ borrower_id: identify the borrower. It is also the primary key of the table crcBORROWER. """ res = run_sql("""SELECT lr.id_crcBORROWER, lr.id_bibrec, lr.status, DATE_FORMAT(lr.period_of_interest_from,'%%Y-%%m-%%d'), DATE_FORMAT(lr.period_of_interest_to,'%%Y-%%m-%%d') FROM crcLOANREQUEST lr WHERE lr.id_crcBORROWER =%s and lr.status!='done' ORDER BY status """, (borrower_id, )) return res def get_borrower_request_details_order_by_from(borrower_id): """ borrower_id: identify the borrower. It is also the primary key of the table crcBORROWER. """ res = run_sql("""SELECT lr.id_crcBORROWER, lr.id_bibrec, lr.status, DATE_FORMAT(lr.period_of_interest_from,'%%Y-%%m-%%d'), DATE_FORMAT(lr.period_of_interest_to,'%%Y-%%m-%%d') FROM crcLOANREQUEST lr WHERE lr.id_crcBORROWER =%s and lr.status!='done' ORDER BY period_of_interest_from """, (borrower_id, )) return res def get_borrower_request_details_order_by_to(borrower_id): """ borrower_id: identify the borrower. It is also the primary key of the table crcBORROWER. """ res = run_sql("""SELECT lr.id_crcBORROWER, lr.id_bibrec, lr.status, DATE_FORMAT(lr.period_of_interest_from,'%%Y-%%m-%%d'), DATE_FORMAT(lr.period_of_interest_to,'%%Y-%%m-%%d') FROM crcLOANREQUEST lr WHERE lr.id_crcBORROWER =%s and lr.status!='done' ORDER BY period_of_interest_to """, (borrower_id, )) return res def new_loan(borrower_id, recid, barcode, loaned_on, due_date, status, loan_type, notes): """ Create a new loan. 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. barcode: identify the item. It is the primary key of the table crcITEM. loaned_on: loan date. due_date: due date. status: loan status. loan_type: loan type(normal, ILL, etc...) notes: loan notes. """ res = run_sql(""" insert into crcLOAN (id_crcBORROWER, id_bibrec, barcode, loaned_on, due_date, status, type, notes) values(%s, %s, %s, %s, %s, %s ,%s, %s) """, (borrower_id, recid, barcode, loaned_on, due_date, status, loan_type, str(notes))) return res def get_item_loans(recid): """ recid: identify the record. It is also the primary key of the table bibrec. """ res = run_sql( """ select bor.id, bor.name, l.barcode, DATE_FORMAT(l.loaned_on,'%%Y-%%m-%%d'), DATE_FORMAT(l.due_date,'%%Y-%%m-%%d'), l.number_of_renewals, l.overdue_letter_number, DATE_FORMAT(l.overdue_letter_date,'%%Y-%%m-%%d'), l.status, l.notes, l.id from crcLOAN l, crcBORROWER bor, crcITEM it where l.id_crcBORROWER = bor.id and l.barcode=it.barcode and l.id_bibrec=%s and l.status!='returned' """, (recid, )) return res def get_all_loans(limit): """ Get all loans. """ res = run_sql( """ SELECT bor.id, bor.name, it.id_bibrec, l.barcode, DATE_FORMAT(l.loaned_on,'%%Y-%%m-%%d'), DATE_FORMAT(l.due_date,'%%Y-%%m-%%d'), l.number_of_renewals, l.overdue_letter_number, DATE_FORMAT(l.overdue_letter_date,'%%Y-%%m-%%d'), l.notes, l.id FROM crcLOAN l, crcBORROWER bor, crcITEM it WHERE l.id_crcBORROWER = bor.id and l.barcode = it.barcode and l.status = 'on loan' ORDER BY 5 DESC LIMIT 0,%s """, (limit,)) return res def get_all_expired_loans(): """ Get all expired(overdue) loans. """ res = run_sql( """ select bor.id, bor.name, it.id_bibrec, l.barcode, DATE_FORMAT(l.loaned_on,'%Y-%m-%d'), DATE_FORMAT(l.due_date,'%Y-%m-%d'), l.number_of_renewals, l.overdue_letter_number, DATE_FORMAT(l.overdue_letter_date,'%Y-%m-%d'), l.notes, l.id from crcLOAN l, crcBORROWER bor, crcITEM it where l.id_crcBORROWER = bor.id and l.barcode = it.barcode and l.status = 'on loan' and l.due_date < CURDATE() """) # l.status='expired' return res def get_borrower_loans(borrower_id): """ borrower_id: identify the borrower. It is also the primary key of the table crcBORROWER. """ res = run_sql(""" select id_bibrec, barcode, DATE_FORMAT(loaned_on,'%%Y-%%m-%%d'), DATE_FORMAT(due_date,'%%Y-%%m-%%d'), type from crcLOAN where id_crcBORROWER=%s and status != 'returned' """, (borrower_id, )) return res def update_due_date(loan_id, new_due_date): """ loan_id: identify a loan. It is the primery key of the table crcLOAN. new_due_date: new due date. """ return int(run_sql("""UPDATE crcLOAN SET due_date=%s, number_of_renewals = number_of_renewals + 1 WHERE id=%s""", (new_due_date, loan_id))) def update_due_date_borrower(borrower_id, new_due_date): """ borrower_id: identify the borrower. It is also the primary key of the table crcBORROWER. new_due_date: new due date. """ return int(run_sql("""UPDATE crcLOAN SET due_date=%s WHERE id_crcBORROWER=%s and status='on loan' """, (new_due_date, borrower_id))) def get_queue_request(recid): """ recid: identify the record. It is also the primary key of the table bibrec. """ res = run_sql(""" select id from crcLOANREQUEST where id_bibrec=%s and (status='pending' or status='waiting') """, (recid, )) return res def get_recid_borrower_loans(borrower_id): """ borrower_id: identify the borrower. It is also the primary key of the table crcBORROWER. """ res = run_sql(""" select id, id_bibrec, barcode from crcLOAN where id_crcBORROWER=%s and status != 'returned'and type != 'ill' """, (borrower_id, )) return res def update_request_barcode(barcode, request_id): """ Update the barcode of an hold request. barcode: new barcode (after update). It is also the primary key of the crcITEM table. request_id: identify the hold request who will be cancelled. It is also the primary key of the crcLOANREQUEST table. """ run_sql("""update crcLOANREQUEST set barcode = %s where id = %s """, (barcode, request_id)) def get_historical_overview(borrower_id): """ Get historical information overview (recid, loan date, return date and number of renewals). borrower_id: identify the borrower. All the old (returned) loans associate to this borrower will be retrieved. It is also the primary key of the crcBORROWER table. """ res = run_sql("""select id_bibrec, DATE_FORMAT(loaned_on,'%%Y-%%m-%%d'), returned_on, number_of_renewals from crcLOAN where id_crcBORROWER = %s and status = "returned"; """, (borrower_id, )) return res def get_borrower_requests(borrower_id): """ Get the hold requests of a borrower. borrower_id: identify the borrower. All the hold requests associate to this borrower will be retrieved. It is also the primary key of the crcBORROWER table. """ res = run_sql(""" select id, id_bibrec, DATE_FORMAT(request_date,'%%Y-%%m-%%d'), status from crcLOANREQUEST where id_crcBORROWER=%s and (status='pending' or status='waiting')""", (borrower_id, )) return res def cancel_request(request_id, status): """ Cancel an hold request. request_id: identify the hold request who will be cancelled. It is also the primary key of the crcLOANREQUEST table. status: The new status of the hold request. In this case it will be 'cancelled'. """ run_sql("""update crcLOANREQUEST set status=%s where id=%s """, (status, request_id)) def get_nb_copies_on_loan(recid): """ Get the number of copies on loan for a recid. recid: CDS Invenio record identifier. The number of copies of this record will be retrieved. """ res = run_sql("""select id_bibrec from crcLOAN where id_bibrec=%s and status='on loan'; """, (recid, )) return res def get_loans_notes(loan_id): """ Get loan's notes. loan_id: identify the loan. The notes of this loan will be retrieved. It is also the primary key of the table crcLOAN. """ res = run_sql("""select notes from crcLOAN where id=%s """, (loan_id, )) if res: return res[0][0] else: return None def add_new_note(new_note, borrower_id): """ Add a new borrower's note. new_note: note who will be added. borrower_id: identify the borrower. A new note will be associate to this borrower. It is also the primary key of the crcBORROWER table. """ run_sql("""update crcBORROWER set notes=concat(notes,%s) where id=%s; """, (new_note, borrower_id)) def add_new_loan_note(new_note, loan_id): """ Add a new loan's note. new_note: note who will be added. loan_id: identify the loan. A new note will added to this loan. It is also the primary key of the table crcLOAN. """ run_sql("""update crcLOAN set notes=concat(notes,%s) where id=%s; """, (new_note, loan_id)) def is_borrower(email): """ Verify if someone is a borrower, using the email. email: borrower's email. """ res = run_sql("""select id from crcBORROWER where email=%s""", (email, )) if res: return res[0][0] else: return 0 def new_borrower(name, email, phone, address, mailbox, notes): """ Add/Register a new borrower on the crcBORROWER table. name: borrower's name. email: borrower's email. phone: borrower's phone. address: borrower's address. """ run_sql("""insert into crcBORROWER (name, email, phone, address, mailbox, borrower_since, borrower_until, notes) values(%s, %s, %s, %s, %s, NOW(), '0000-00-00 00:00:00', %s)""", (name, email, phone, address, mailbox, notes)) def get_borrower_address(email): """ Get the address of a borrower using the email. email: borrower's email. """ res = run_sql("""select address from crcBORROWER where email=%s""", (email, )) if len(res[0][0]) > 0: return res[0][0] else: return 0 def add_borrower_address(address, email): """ Add the email and the address of a borrower. address: borrower's address. email: borrower's email. """ run_sql("""update crcBORROWER set address=%s where email=%s""", (address, email)) def get_invenio_user_email(uid): """ Get the email of an invenio's user. uid: identify an invenio's user. """ res = run_sql("""select email from user where id=%s""", (uid, )) if res: return res[0][0] else: return None def get_borrower_notes(borrower_id): """ Get the notes of a borrower. borrower_id: identify the borrower. The data associate to this borrower will be retrieved. It is also the primary key of the crcBORROWER table. """ res = run_sql("""select notes from crcBORROWER where id=%s""", (borrower_id, )) if res: return res[0][0] else: return None def update_loan_status(status, loan_id): """ Update the status of a loan. status: new status (after update) loan_id: identify the loan who will be updated. It is also the primary key of the table crcLOAN. """ run_sql("""update crcLOAN set status = %s where id = %s""", (status, loan_id)) def get_loan_due_date(loan_id): """ Get the due date of a loan. loan_id: identify the loan. The due date of this loan will be retrieved. It is also the primary key of the table crcLOAN. """ res = run_sql("""select DATE_FORMAT(due_date, '%%Y-%%m-%%d') from crcLOAN where id = %s""", (loan_id, )) if res: return res[0][0] else: return None def get_pdf_request_data(status): """ status: request status. """ res = run_sql("""SELECT DISTINCT lr.id_bibrec, bor.name, lib.name, it.location, DATE_FORMAT(lr.period_of_interest_from,'%%Y-%%m-%%d'), DATE_FORMAT(lr.period_of_interest_to,'%%Y-%%m-%%d'), lr.request_date FROM crcLOANREQUEST lr, crcBORROWER bor, crcITEM it, crcLIBRARY lib WHERE lr.id_crcBORROWER=bor.id AND it.id_bibrec=lr.id_bibrec AND lib.id = it.id_crcLIBRARY AND lr.status=%s; """ , (status, )) return res def get_last_loan(): """ Get the recid, the borrower_id and the due date of the last loan who was registered on the crcLOAN table. """ res = run_sql("""select id_bibrec, id_crcBORROWER, DATE_FORMAT(due_date, '%Y-%m-%d') from crcLOAN ORDER BY id DESC LIMIT 1""") if res: return res[0] else: return None def get_borrower_data(borrower_id): """ Get the borrower's information (name, address and email). borrower_id: identify the borrower. The data associate to this borrower will be retrieved. It is also the primary key of the crcBORROWER table. """ res = run_sql("""select name, address, mailbox, email from crcBORROWER where id=%s""", (borrower_id, )) if res: return res[0] else: return None def update_borrower_info(borrower_id, name, email, phone, address, mailbox): """ Update borrower info. borrower_id: identify the borrower. It is also the primary key of the table crcBORROWER. """ return int(run_sql("""update crcBORROWER set name=%s, email=%s, phone=%s, address=%s, mailbox=%s where id=%s""", (name, email, phone, address, mailbox, borrower_id))) -def add_new_library(name, email, phone, address, type, notes): +def add_new_library(name, email, phone, address, lib_type, notes): """ Add a new Library. """ run_sql("""insert into crcLIBRARY (name, email, phone, address, type, notes) values (%s, %s, %s, %s, %s, %s)""", - (name, email, phone, address, type, notes)) + (name, email, phone, address, lib_type, notes)) def search_library_by_name(string): """ string: search pattern. """ res = run_sql("""select id, name from crcLIBRARY where name regexp %s """, (string, )) return res def search_library_by_email(string): """ string: search pattern. """ res = run_sql("""select id, name from crcLIBRARY where email regexp %s """, (string, )) return res def get_all_libraries(): """ """ res = run_sql("""select id, name from crcLIBRARY""") return res def update_library_info(library_id, name, email, phone, address): """ Update library information. library_id: identify the library. It is also the primary key of the table crcLIBRARY. """ return int(run_sql("""update crcLIBRARY set name=%s, email=%s, phone=%s, address=%s where id=%s""", (name, email, phone, address, library_id))) def get_libraries(): """ Get Libraries """ res = run_sql("""select id, name from crcLIBRARY""") #where type<>'external' """) return res def get_library_name(library_id): """ Get Library's name. library_id: identify the library. It is also the primary key of the table crcLIBRARY. """ res = run_sql("""select name from crcLIBRARY where id=%s""", (library_id, )) if res: return res[0][0] else: return None def add_new_copy(barcode, recid, library_id, collection, location, description, loan_period, status): """ Add a new copy 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. library_id: identify the library. It is also the primary key of the table crcLIBRARY. """ run_sql("""insert into crcITEM (barcode, id_bibrec, id_crcLIBRARY, collection, location, description, loan_period, status, creation_date, modification_date) values (%s, %s, %s, %s, %s, %s, %s, %s, NOW(), NOW())""", (barcode, recid, library_id, collection, location, description, loan_period, status)) def get_item_info(barcode): """ Get item's information. barcode: identify the item. It is the primary key of the table crcITEM. """ res = run_sql("""select it.barcode, it.id_crcLIBRARY, lib.name, it.collection, it.location, it.description, it.loan_period, it.status from crcITEM it, crcLIBRARY lib where it.barcode=%s and it.id_crcLIBRARY = lib.id""", (barcode, )) if res: return res[0] else: return None def update_item_info(barcode, library_id, collection, location, description, loan_period, status): """ Update item's information. barcode: identify the item. It is the primary key of the table crcITEM. library_id: identify the library. It is also the primary key of the table crcLIBRARY. """ int(run_sql("""update crcITEM set barcode=%s, id_crcLIBRARY=%s, collection=%s, location=%s, description=%s, loan_period=%s, status=%s, modification_date=NOW() where barcode=%s""", (barcode, library_id, collection, location, description, loan_period, status, barcode))) def get_library_items(library_id): """ Get all items who belong to a library. library_id: identify the library. It is also the primary key of the table crcLIBRARY. """ res = run_sql("""select barcode, id_bibrec, collection, location, description, loan_period, status, number_of_requests from crcITEM where id_crcLIBRARY=%s""", (library_id, )) return res def get_library_notes(library_id): """ Get the notes of a library. library_id: identify the library. The data associate to this library will be retrieved. It is also the primary key of the crcLIBRARY table. """ res = run_sql("""select notes from crcLIBRARY where id=%s""", (library_id, )) if res: return res[0][0] else: return None def add_new_library_note(new_note, library_id): """ Add a new borrower's note. new_note: note who will be added. library_id: identify the borrower. A new note will be associate to this borrower. It is also the primary key of the crcBORROWER table. """ run_sql("""update crcLIBRARY set notes=concat(notes,%s) where id=%s; """, (new_note, library_id)) def get_borrower_data_by_name(name): """ Retrieve borrower's data by name. """ res = run_sql("""select id, name, email, phone, address, mailbox from crcBORROWER where name regexp %s order by name""", (name, )) return res def get_borrower_data_by_email(email): """ Retrieve borrower's data by email. """ res = run_sql("""select id, name, email, phone, address, mailbox from crcBORROWER where email regexp %s""", (email, )) return res def get_borrower_data_by_id(borrower_id): """ Retrieve borrower's data by borrower_id. """ res = run_sql("""select id, name, email, phone, address, mailbox from crcBORROWER where id regexp %s""", (borrower_id, )) return res def get_number_requests_per_copy(barcode): """ barcode: identify the item. It is the primary key of the table crcITEM. """ res = run_sql("""select count(barcode) from crcLOANREQUEST where barcode=%s and (status != 'done' and status != 'cancelled')""", (barcode, )) return res[0][0] def get_requested_barcode(request_id): """ request_id: identify the hold request. It is also the primary key of the table crcLOANREQUEST. """ res = run_sql("""select barcode from crcLOANREQUEST where id=%s""", (request_id, )) if res: return res[0][0] else: return None def get_borrower_recids(borrower_id): """ borrower_id: identify the borrower. It is also the primary key of the table crcBORROWER. """ res = run_sql("""select id_bibrec from crcLOAN where id_crcBORROWER=%s""", (borrower_id,)) return res def get_loan_status(loan_id): """ Get loan's status loan_id: identify a loan. It is the primery key of the table crcLOAN. """ res = run_sql("""select status from crcLOAN where id=%s""", (loan_id, )) if res: return res[0][0] else: return None def get_loan_period(barcode): """ Retrieve the loan period of a book. barcode: identify the item. It is the primary key of the table crcITEM. """ res = run_sql("""select loan_period from crcITEM where barcode=%s""", (barcode, )) if res: return res[0][0] else: return None def get_loan_infos(loan_id): """ loan_id: identify a loan. It is the primery key of the table crcLOAN. """ res = run_sql("""select l.id_bibrec, l.barcode, DATE_FORMAT(l.loaned_on, '%%Y-%%m-%%d'), DATE_FORMAT(l.due_date, '%%Y-%%m-%%d'), l.status, it.loan_period, it.status from crcLOAN l, crcITEM it, crcLOANREQUEST lr where l.barcode=it.barcode and l.id=%s""", (loan_id, )) if res: return res[0] else: return None def is_item_on_loan(barcode): """ Check if an item is on loan. barcode: identify the item. It is the primary key of the table crcITEM. """ res = run_sql("""select id from crcLOAN where (status='on loan' or status='expired') and barcode=%s""", (barcode, )) try: return res[0][0] except IndexError: return None def order_new_copy(recid, vendor_id, order_date, cost, status, notes, expected_date): """ Register a new copy who has been ordered. """ run_sql("""insert into crcPURCHASE(id_bibrec, id_crcVENDOR, ordered_date, price, status, notes, expected_date) values (%s, %s, %s, %s, %s, %s, %s)""", (recid, vendor_id, order_date, cost, status, notes, expected_date)) def get_ordered_books(): """ Get the list with all the ordered books. """ res = run_sql("""select id, id_bibrec, id_crcVENDOR, DATE_FORMAT(ordered_date,'%Y-%m-%d'), DATE_FORMAT(expected_date, '%Y-%m-%d'), price, status, notes from crcPURCHASE""") return res def get_purchase_notes(purchase_id): """ Get the notes of a purchase. library_id: identify the purchase. The data associate to this library will be retrieved. It is also the primary key of the crcPURCHASE table. """ res = run_sql("""select notes from crcPURCHASE where id=%s""", (purchase_id, )) if res: return res[0][0] else: return None def update_purchase_notes(purchase_id, purchase_notes): """ """ run_sql("""update crcPURCHASE set notes=%s where id=%s """, (str(purchase_notes), purchase_id)) def add_new_purchase_note(new_note, purchase_id): """ Add a new purchase's note. new_note: note who will be added. library_id: identify the purchase. A new note will be associate to this purchase. It is also the primary key of the crcPURCHASE table. """ run_sql("""update crcPURCHASE set notes=concat(notes,%s) where id=%s; """, (new_note, purchase_id)) def ill_register_request(book_info, borrower_id, period_of_interest_from, period_of_interest_to, status, additional_comments, only_edition): """ """ run_sql("""insert into crcILLREQUEST(id_crcBORROWER, period_of_interest_from, period_of_interest_to, status, book_info, borrower_comments, only_this_edition) values (%s, %s, %s, %s, %s, %s, %s)""", (borrower_id, period_of_interest_from, period_of_interest_to, status, str(book_info), additional_comments, only_edition)) def ill_register_request_on_desk(borrower_id, book_info, period_of_interest_from, period_of_interest_to, status, notes, only_edition): """ """ run_sql("""insert into crcILLREQUEST(id_crcBORROWER, period_of_interest_from, period_of_interest_to, status, book_info, only_this_edition, library_notes) values (%s, %s, %s, %s, %s, %s, %s)""", (borrower_id, period_of_interest_from, period_of_interest_to, status, str(book_info), only_edition, notes)) def get_ill_requests(): """ """ query = """select ill.id, ill.id_crcBORROWER, bor.name, ill.id_crcLIBRARY, ill.status, DATE_FORMAT(ill.period_of_interest_from,'%Y-%m-%d'), DATE_FORMAT(ill.period_of_interest_to,'%Y-%m-%d'), ill.book_info from crcILLREQUEST ill, crcBORROWER bor where ill.id_crcBORROWER=bor.id order by ill.id desc""" res = run_sql(query) return res def get_ill_request_pending(ill_request_id): """ """ res = run_sql("""select library_notes from crcILLREQUEST where id=%s""", (ill_request_id, )) if res: return res[0][0] else: return None def get_ill_request_sent(ill_request_id): """ """ res = run_sql("""select id_crcLIBRARY, DATE_FORMAT(request_date,'%%Y-%%m-%%d'), DATE_FORMAT(expected_date,'%%Y-%%m-%%d'), cost, barcode, library_notes from crcILLREQUEST where id=%s""", (ill_request_id, )) if res: return res[0] else: return None def get_ill_request_cancelled(ill_request_id): """ """ res = run_sql("""select id_crcLIBRARY, DATE_FORMAT(request_date,'%%Y-%%m-%%d'), DATE_FORMAT(expected_date,'%%Y-%%m-%%d'), library_notes from crcILLREQUEST where id=%s""", (ill_request_id, )) if res: return res[0] else: return None def get_ill_request_received(ill_request_id): """ """ res = run_sql("""select id_crcLIBRARY, DATE_FORMAT(request_date,'%%Y-%%m-%%d'), DATE_FORMAT(expected_date,'%%Y-%%m-%%d'), DATE_FORMAT(arrival_date,'%%Y-%%m-%%d'), DATE_FORMAT(due_date,'%%Y-%%m-%%d'), cost, barcode, library_notes from crcILLREQUEST where id=%s""", (ill_request_id, )) if res: return res[0] else: return None def get_ill_request_returned(ill_request_id): """ """ res = run_sql("""select id_crcLIBRARY, DATE_FORMAT(request_date,'%%Y-%%m-%%d'), DATE_FORMAT(expected_date,'%%Y-%%m-%%d'), DATE_FORMAT(arrival_date,'%%Y-%%m-%%d'), DATE_FORMAT(due_date,'%%Y-%%m-%%d'), DATE_FORMAT(return_date,'%%Y-%%m-%%d'), cost, barcode, library_notes from crcILLREQUEST where id=%s""", (ill_request_id, )) if res: return res[0] else: return None def get_ill_item_received(ill_request_id): """ """ res = run_sql("""select id_crcLIBRARY, DATE_FORMAT(request_date,'%%Y-%%m-%%d'), DATE_FORMAT(expected_date,'%%Y-%%m-%%d'), library_notes from crcILLREQUEST where id=%s""", (ill_request_id, )) if res: return res[0] else: return None def get_ill_item_returned(ill_request_id): """ """ res = run_sql("""select id_crcLIBRARY, DATE_FORMAT(request_date,'%%Y-%%m-%%d'), DATE_FORMAT(expected_date,'%%Y-%%m-%%d'), DATE_FORMAT(arrival_date,'%%Y-%%m-%%d'), DATE_FORMAT(due_date,'%%Y-%%m-%%d'), barcode, library_notes from crcILLREQUEST where id=%s""", (ill_request_id, )) if res: return res[0] else: return None def get_ill_request_closed(ill_request_id): """ """ res = run_sql("""select id_crcLIBRARY, DATE_FORMAT(request_date,'%%Y-%%m-%%d'), DATE_FORMAT(expected_date,'%%Y-%%m-%%d'), DATE_FORMAT(arrival_date,'%%Y-%%m-%%d'), DATE_FORMAT(due_date,'%%Y-%%m-%%d'), DATE_FORMAT(return_date,'%%Y-%%m-%%d'), cost, barcode, library_notes from crcILLREQUEST where id=%s""", (ill_request_id, )) if res: return res[0] else: return None def get_ill_borrower_request(ill_request_id): """ """ res = run_sql("""select ill.id_crcBORROWER, bor.name, bor.email, bor.mailbox, DATE_FORMAT(ill.period_of_interest_from,'%%Y-%%m-%%d'), DATE_FORMAT(ill.period_of_interest_to,'%%Y-%%m-%%d'), ill.book_info, ill.borrower_comments, ill.only_this_edition from crcILLREQUEST ill, crcBORROWER bor where ill.id_crcBORROWER=bor.id and ill.id=%s""", (ill_request_id, )) if res: return res[0] else: return None def get_external_libraries(): """ Get Libraries """ res = run_sql("""select id, name from crcLIBRARY where type='external' """) return res def update_ill_request(ill_request_id, library_id, request_date, expected_date, arrival_date, return_date, status, cost, currency, barcode, library_notes): """ Update an ILL request. """ cost_format = cost + ' ' + currency run_sql("""update crcILLREQUEST set id_crcLIBRARY=%s, request_date=%s, expected_date=%s, arrival_date=%s, return_date=%s, status=%s, cost=%s, barcode=%s, library_notes=%s where id=%s""", (library_id, request_date, expected_date, arrival_date, return_date, status, cost_format, barcode, library_notes, ill_request_id)) def update_ill_request_pending(ill_request_id, ill_status, library_notes): """ """ run_sql("""update crcILLREQUEST set status=%s, library_notes=%s where id=%s""", (ill_status, library_notes, ill_request_id)) def update_ill_request_sent(ill_request_id, ill_status, library_id, request_date, expected_date, cost_format, barcode, library_notes): """ """ run_sql("""update crcILLREQUEST set status=%s, id_crcLIBRARY=%s, request_date=%s, expected_date=%s, cost=%s, barcode=%s, library_notes=%s where id=%s""", (ill_status, library_id, request_date, expected_date, cost_format, barcode, library_notes, ill_request_id)) def update_ill_request_cancelled(ill_request_id, ill_status, cost_format, barcode, library_notes): """ """ run_sql("""update crcILLREQUEST set status=%s, cost=%s, barcode=%s, library_notes=%s where id=%s""", (ill_status, cost_format, barcode, library_notes, ill_request_id)) def update_ill_item_received(ill_request_id, ill_status, arrival_date, due_date, cost_format, barcode, library_notes): """ """ run_sql("""update crcILLREQUEST set status=%s, arrival_date=%s, due_date=%s, cost=%s, barcode=%s, library_notes=%s where id=%s""", (ill_status, arrival_date, due_date, cost_format, barcode, library_notes, ill_request_id)) def update_ill_item_returned(ill_request_id, ill_status, return_date, cost_format, library_notes): """ """ run_sql("""update crcILLREQUEST set status=%s, return_date=%s, cost=%s, library_notes=%s where id=%s""", (ill_status, return_date, cost_format, library_notes, ill_request_id)) def update_ill_request_closed(ill_request_id, ill_status, library_notes): """ """ run_sql("""update crcILLREQUEST set status=%s, library_notes=%s where id=%s""", (ill_status, library_notes, ill_request_id)) def get_order_details(purchase_id): """ """ res = run_sql("""select id, id_bibrec, id_crcVENDOR, DATE_FORMAT(ordered_date,'%%Y-%%m-%%d'), DATE_FORMAT(expected_date,'%%Y-%%m-%%d'), price, status, notes from crcPURCHASE where id=%s""", (purchase_id, )) if res: return res[0] else: return None def uptade_purchase(purchase_id, recid, vendor_id, price, status, order_date, expected_date, notes): """ """ run_sql("""update crcPURCHASE set id_bibrec=%s, id_crcVENDOR=%s, ordered_date=%s, expected_date=%s, price=%s, status=%s, notes=%s where id=%s""", (recid, vendor_id, order_date, expected_date, price, status, notes, purchase_id)) def add_new_vendor(name, email, phone, address, notes): """ Add a new vendor. """ run_sql("""insert into crcVENDOR (name, email, phone, address, notes) values (%s, %s, %s, %s, %s)""", (name, email, phone, address, notes)) def search_vendor_by_name(string): """ string: search pattern. """ res = run_sql("""select id, name from crcVENDOR where name regexp %s """, (string, )) return res def search_vendor_by_email(string): """ string: search pattern. """ res = run_sql("""select id, name from crcVENDOR where email regexp %s """, (string, )) return res def get_all_vendors(): """ """ res = run_sql("""select id, name from crcVENDOR""") return res def update_vendor_info(vendor_id, name, email, phone, address): """ Update vendor information. vendor_id: identify the vendor. It is also the primary key of the table crcVENDOR. """ return int(run_sql("""update crcVENDOR set name=%s, email=%s, phone=%s, address=%s where id=%s""", (name, email, phone, address, vendor_id))) def get_vendors(): """ Get vendors """ res = run_sql("""select id, name from crcVENDOR""") return res def get_vendor_details(vendor_id): """ vendor_id: identify the vendor. It is also the primary key of the table crcVENDOR. """ res = run_sql("""select id, name, address, email, phone, notes from crcVENDOR where id=%s; """, (vendor_id, )) if res: return res[0] else: return None def get_vendor_notes(vendor_id): """ Get the notes of a vendor. vendor_id: identify the vendor. The data associate to this vendor will be retrieved. It is also the primary key of the crcVENDOR table. """ res = run_sql("""select notes from crcVENDOR where id=%s""", (vendor_id, )) if res: return res[0][0] else: return None def add_new_vendor_note(new_note, vendor_id): """ Add a new vendor's note. new_note: note who will be added. vendor_id: identify the vendor. A new note will be associate to this vendor. It is also the primary key of the crcVENDOR table. """ run_sql("""update crcVENDOR set notes=concat(notes,%s) where id=%s; """, (new_note, vendor_id)) def get_list_of_vendors(): """ Get vendors """ res = run_sql("""select id, name from crcVENDOR""") return res def get_vendor_name(vendor_id): """ Get Vendor's name. vendor_id: identify the vendor. It is also the primary key of the table crcVENDOR. """ res = run_sql("""select name from crcVENDOR where id=%s""", (vendor_id, )) if res: return res[0][0] else: return None def get_ill_request_notes(ill_request_id): """ """ res = run_sql("""select library_notes from crcILLREQUEST where id=%s""", (ill_request_id, )) if res: return res[0][0] else: return None def update_ill_request_notes(ill_request_id, library_notes): """ """ run_sql("""update crcILLREQUEST set library_notes=%s where id=%s""", (str(library_notes), ill_request_id)) def get_ill_borrower(ill_request_id): """ """ res = run_sql("""select id_crcBORROWER from crcILLREQUEST where id=%s""", (ill_request_id, )) if res: return res[0][0] else: return None def get_ill_barcode(ill_request_id): """ """ res = run_sql("""select barcode from crcILLREQUEST where id=%s""", (ill_request_id, )) if res: return res[0][0] else: return None -def update_ill_loan_status(borrower_id, barcode, return_date, type): +def update_ill_loan_status(borrower_id, barcode, return_date, loan_type): """ """ run_sql("""update crcLOAN set status = 'returned', returned_on = %s where id_crcBORROWER = %s and barcode = %s and type = %s""", - (return_date, borrower_id, barcode, type)) + (return_date, borrower_id, barcode, loan_type)) def get_recid(barcode): """ Get the id bibrec. barcode: identify the item. It is the primary key of the table crcITEM. """ res = run_sql("""select id_bibrec from crcITEM where barcode=%s""", (barcode, )) try: return res[0] except IndexError: return None def get_ill_requests_details(borrower_id): """ """ res = run_sql("""select id, book_info, id_crcLIBRARY, DATE_FORMAT(request_date,'%%Y-%%m-%%d'), DATE_FORMAT(expected_date,'%%Y-%%m-%%d'), DATE_FORMAT(arrival_date,'%%Y-%%m-%%d'), DATE_FORMAT(due_date,'%%Y-%%m-%%d'), status, library_notes from crcILLREQUEST where id_crcBORROWER=%s and status!='document received, request closed' """, (borrower_id, )) return res def bor_ill_historical_overview(borrower_id): """ """ res = run_sql("""select id, book_info, id_crcLIBRARY, DATE_FORMAT(request_date,'%Y-%m-%d'), DATE_FORMAT(expected_date,'%Y-%m-%d'), DATE_FORMAT(arrival_date,'%Y-%m-%d'), DATE_FORMAT(due_date,'%Y-%m-%d'), status, library_notes from crcILLREQUEST where id_crcBORROWER=%s and status='document received, request closed'""" , (borrower_id, )) return res def get_ill_notes(ill_id): """ """ res = run_sql("""select library_notes from crcILLREQUEST where id=%s""", (ill_id, )) if res: return res[0][0] else: return None def update_ill_notes(ill_id, ill_notes): """ """ run_sql("""update crcILLREQUEST set library_notes=%s where id=%s """, (str(ill_notes), ill_id)) def is_on_loan(barcode): """ """ res = run_sql("""select id from crcLOAN where barcode=%s and status='on loan' """, (barcode, )) if res: return True else: return False def is_requested(barcode): """ """ res = run_sql("""select id from crcLOANREQUEST where barcode=%s and (status = 'pending' or status = 'waiting') """, (barcode, )) try: return res except IndexError: return None def get_lib_location(barcode): """ """ res = run_sql("""select id_crcLIBRARY, location from crcITEM where barcode=%s""", (barcode, )) if res: return res[0] else: return None def get_barcodes(recid): """ """ res = run_sql("""select barcode from crcITEM where id_bibrec=%s""", (recid, )) barcodes = [] for i in range(len(res)): barcodes.append(res[i][0]) return barcodes def barcode_in_use(barcode): """ """ res = run_sql("""select id_bibrec from crcITEM where barcode=%s""", (barcode, )) if res: return True else: return False def get_expired_loans_with_requests(): """ """ res = run_sql("""SELECT DISTINCT lr.id, lr.id_bibrec, lr.id_crcBORROWER, it.id_crcLIBRARY, it.location, DATE_FORMAT(lr.period_of_interest_from,'%Y-%m-%d'), DATE_FORMAT(lr.period_of_interest_to,'%Y-%m-%d'), lr.request_date FROM crcLOANREQUEST lr, crcITEM it, crcLOAN l WHERE it.barcode=lr.barcode AND lr.barcode=l.barcode AND (lr.status='pending' or lr.status='waiting') AND l.status='on loan' and l.due_date < CURDATE() ORDER BY lr.request_date; """) return res def get_total_of_loans(): """ """ res = run_sql("""select count(id) from crcLOAN where status='on loan';""") return res[0][0] def update_borrower_notes(borrower_id, borrower_notes): """ """ run_sql("""update crcBORROWER set notes=%s where id=%s """, (str(borrower_notes), borrower_id)) def get_loan_notes(loan_id): """ """ res = run_sql("""select notes from crcLOAN where id=%s""", (loan_id, )) if res: return res[0][0] else: return None def update_loan_notes(loan_id, loan_notes): """ """ run_sql("""update crcLOAN set notes=%s where id=%s """, (str(loan_notes), loan_id)) def update_library_notes(library_id, library_notes): """ """ run_sql("""update crcLIBRARY set notes=%s where id=%s """, (str(library_notes), library_id)) def get_ill_book_info(ill_request_id): """ """ res = run_sql("""select book_info from crcILLREQUEST where id=%s""", (ill_request_id, )) if res: return res[0][0] else: return None def get_ill_ids(): """ """ res = run_sql("""select id from crcILLREQUEST where status!='document received, request closed'""") return res def get_copies_status(recid): """ """ res = run_sql("""select status from crcITEM where id_bibrec=%s""", (recid, )) if res: return res[0] else: return None def get_loan_recid(loan_id): """ """ res = run_sql("""select id_bibrec from crcLOAN where id=%s""", (loan_id, )) if res: return res[0][0] else: return None diff --git a/modules/bibcirculation/lib/bibcirculation_regression_tests.py b/modules/bibcirculation/lib/bibcirculation_regression_tests.py index 039e4e442..5e10bec8a 100644 --- a/modules/bibcirculation/lib/bibcirculation_regression_tests.py +++ b/modules/bibcirculation/lib/bibcirculation_regression_tests.py @@ -1,76 +1,75 @@ # -*- 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 Regression Test Suite.""" __revision__ = "$Id$" import unittest from invenio.config import CFG_SITE_URL from invenio.testutils import make_test_suite, run_test_suite, \ - test_web_page_content, merge_error_messages, \ - test_web_page_existence + test_web_page_content, merge_error_messages class BibCirculationUsersWebPagesAvailabilityTest(unittest.TestCase): """Check BibCirculation web pages whether they are up or not.""" def test_your_loans_page_availability(self): """bibcirculation - availability of your loans page""" baseurl = CFG_SITE_URL + '/yourloans/' _exports = ['', 'display', 'loanshistoricaloverview'] error_messages = [] for url in [baseurl + page for page in _exports]: error_messages.extend(test_web_page_content(url)) if error_messages: self.fail(merge_error_messages(error_messages)) return class BibCirculationAdminsWebPagesAvailabilityTest(unittest.TestCase): """Check BibCirculation web pages whether they are up or not for Admins.""" def test_admin_pages_availability(self): """bibcirculation - availability of main admin page""" baseurl = CFG_SITE_URL + '/admin/bibcirculation/bibcirculationadmin.py' self.assertEqual([], test_web_page_content(baseurl, expected_text="BibCirculation Admin")) return def test_borrower_search_availability(self): """bibcirculation - availability of borrower search""" baseurl = CFG_SITE_URL + '/admin/bibcirculation/bibcirculationadmin.py/' \ + 'borrower_search_result?column=name&string=john' self.assertEqual([], test_web_page_content(baseurl, username='admin', expected_text='Borrower search result')) return TEST_SUITE = make_test_suite(BibCirculationUsersWebPagesAvailabilityTest, BibCirculationAdminsWebPagesAvailabilityTest) if __name__ == "__main__": run_test_suite(TEST_SUITE, warn_user=True) diff --git a/modules/bibcirculation/lib/bibcirculation_templates.py b/modules/bibcirculation/lib/bibcirculation_templates.py index c022e82ae..bbb04f2dd 100644 --- a/modules/bibcirculation/lib/bibcirculation_templates.py +++ b/modules/bibcirculation/lib/bibcirculation_templates.py @@ -1,16607 +1,16605 @@ # -*- 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 += """ """ % (_("Barcode"), _("Library"), _("Collection"), _("Location"), _("Description"), _("Loan period"), _("Status"), _("Due date"), _("Option(s)")) 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 += """ """ % (barcode, library, collection or '-', location, description or '-', loan_period, status, due_date or '-', request_button) from invenio.bibcirculationadminlib import is_adminuser (auth_code, _auth_message) = is_adminuser(req) if auth_code != 0: - bibcirc_link = '' + bibcirc_link = '' else: bibcirc_link = create_html_link(CFG_SITE_URL + '/admin/bibcirculation/bibcirculationadmin.py/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, ln=CFG_SITE_LANG): + def tmpl_book_not_for_loan(self): message = """
This item is not for loan.
""" return message - def tmpl_message_request_send_ok_cern(self, ln=CFG_SITE_LANG): + 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, ln=CFG_SITE_LANG): + 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, ln=CFG_SITE_LANG): + 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 borrower(s) found.")) 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 + '/admin/bibcirculation/bibcirculationadmin.py/get_borrower_details', {'borrower_id': borrower_id, 'ln': ln}, (name)) else: borrower_link = create_html_link(CFG_SITE_URL + '/admin/bibcirculation/bibcirculationadmin.py/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, uid, recid, barcode, ln=CFG_SITE_LANG): + 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 $(function() { $("#date_picker2").datepicker({dateFormat: 'yy-mm-dd', showOn: 'button', buttonImage: "%s/img/calendar.gif", buttonImageOnly: true}); });




""" % (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 = """ """ 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 + '/admin/bibcirculation/bibcirculationadmin.py/get_item_details', {'recid': recid, 'ln': ln}, (book_title_from_MARC(recid))) borrower_link = create_html_link(CFG_SITE_URL + '/admin/bibcirculation/bibcirculationadmin.py/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 + '/admin/bibcirculation/bibcirculationadmin.py/get_item_details', {'recid': recid, 'ln': ln}, (book_title_from_MARC(recid))) borrower_link = create_html_link(CFG_SITE_URL + '/admin/bibcirculation/bibcirculationadmin.py/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 + %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 + '/admin/bibcirculation/bibcirculationadmin.py/get_borrower_details', {'borrower_id': borrower_id, 'ln': ln}, (borrower_name)) title_link = create_html_link(CFG_SITE_URL + '/admin/bibcirculation/bibcirculationadmin.py/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)) + (_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) out = self.tmpl_infobox(infos, ln) out += _MENU_ out += """ -
+



%s ccid name email






""" % (CFG_SITE_URL, _("Search borrower by"),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 len(result) == 0: - out += """ + out += """

%s

""" % (_("0 item(s) 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 + '/admin/bibcirculation/bibcirculationadmin.py/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 - + 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 - + 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 """ (ccid, name, email, phone, address, mailbox) = user_info _ = gettext_set_language(ln) 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, _("User information"), _("ID"), ccid, _("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 """ (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) 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"), ccid, _("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, 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) 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



""" % (_("A new loan has been registered."), _("Name"), name, _("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 + '/admin/bibcirculation/bibcirculationadmin.py/get_borrower_details', {'borrower_id': borid, 'ln': ln}, (name)) title_link = create_html_link(CFG_SITE_URL + '/admin/bibcirculation/bibcirculationadmin.py/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 + '/admin/bibcirculation/bibcirculationadmin.py/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: book_cover = get_book_cover(book_isbn) 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 item"), str(book_cover), _("Additional details")) out += """ """ % (_("Barcode"), _("Status"), _("Due date"), _("Library"), _("Location"), _("Loan period"), _("No of loans"), _("Collection"), _("Description"), _("Action(s)")) 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 + '/admin/bibcirculation/bibcirculationadmin.py/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) elif status == 'Not for loan': out += """ """ % (barcode, barcode, barcode) else: out += """ """ % (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 + '/admin/bibcirculation/bibcirculationadmin.py/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) = None 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 + '/admin/bibcirculation/bibcirculationadmin.py/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 + '/admin/bibcirculation/bibcirculationadmin.py/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 + '/admin/bibcirculation/bibcirculationadmin.py/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 + '/admin/bibcirculation/bibcirculationadmin.py/get_library_notes', {'library_id': library_id}, (_("No notes"))) see_notes_link = create_html_link(CFG_SITE_URL + '/admin/bibcirculation/bibcirculationadmin.py/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_ (borrower_id, name, email, phone, address, mailbox) = borrower - req_link = create_html_link(CFG_SITE_URL + - '/admin/bibcirculation/bibcirculationadmin.py/get_borrower_requests_details', - {'borrower_id': borrower_id}, - (_("More details"))) + #req_link = create_html_link(CFG_SITE_URL + + # '/admin/bibcirculation/bibcirculationadmin.py/get_borrower_requests_details', + # {'borrower_id': borrower_id}, + # (_("More details"))) no_notes_link = create_html_link(CFG_SITE_URL + '/admin/bibcirculation/bibcirculationadmin.py/get_borrower_notes', {'borrower_id': borrower_id}, (_("No notes"))) see_notes_link = create_html_link(CFG_SITE_URL + '/admin/bibcirculation/bibcirculationadmin.py/get_borrower_notes', {'borrower_id': borrower_id}, (_("Notes about this borrower"))) - loans_link = create_html_link(CFG_SITE_URL + - '/admin/bibcirculation/bibcirculationadmin.py/get_borrower_loans_details', - {'borrower_id': borrower_id}, - (_("More details"))) - - ill_link = create_html_link(CFG_SITE_URL + - '/admin/bibcirculation/bibcirculationadmin.py/get_borrower_ill_details', - {'borrower_id': borrower_id}, - (_("More details"))) - - req_hist_link = create_html_link(CFG_SITE_URL + - '/admin/bibcirculation/bibcirculationadmin.py/bor_requests_historical_overview', - {'borrower_id': borrower_id}, - (_("More details"))) - - loans_hist_link = create_html_link(CFG_SITE_URL + - '/admin/bibcirculation/bibcirculationadmin.py/bor_loans_historical_overview', - {'borrower_id': borrower_id}, - (_("More details"))) - - ill_hist_link = create_html_link(CFG_SITE_URL + - '/admin/bibcirculation/bibcirculationadmin.py/bor_ill_historical_overview', - {'borrower_id': borrower_id}, - (_("More details"))) + #loans_link = create_html_link(CFG_SITE_URL + + # '/admin/bibcirculation/bibcirculationadmin.py/get_borrower_loans_details', + # {'borrower_id': borrower_id}, + # (_("More details"))) + # + #ill_link = create_html_link(CFG_SITE_URL + + # '/admin/bibcirculation/bibcirculationadmin.py/get_borrower_ill_details', + # {'borrower_id': borrower_id}, + # (_("More details"))) + # + #req_hist_link = create_html_link(CFG_SITE_URL + + # '/admin/bibcirculation/bibcirculationadmin.py/bor_requests_historical_overview', + # {'borrower_id': borrower_id}, + # (_("More details"))) + # + #loans_hist_link = create_html_link(CFG_SITE_URL + + # '/admin/bibcirculation/bibcirculationadmin.py/bor_loans_historical_overview', + # {'borrower_id': borrower_id}, + # (_("More details"))) + # + #ill_hist_link = create_html_link(CFG_SITE_URL + + # '/admin/bibcirculation/bibcirculationadmin.py/bor_ill_historical_overview', + # {'borrower_id': borrower_id}, + # (_("More details"))) if notes == "" or str(notes) == '{}': check_notes = no_notes_link else: check_notes = see_notes_link out += """

%s
""" % (CFG_SITE_URL, borrower_id, _("Personal details"), _("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


""" % (CFG_SITE_URL, borrower_id, _("Update"), CFG_SITE_URL, borrower_id, name, email, phone, address, mailbox, _("New loan"), CFG_SITE_URL, borrower_id, _("New request"), CFG_SITE_URL, borrower_id, _("New ILL request"), _("Notify this borrower"), _("Requests, Loans and ILL overview on"), time.ctime(), _("Requests"), nb_requests, CFG_SITE_URL, borrower_id, _("More details"), _("Loans"), nb_loans, CFG_SITE_URL, borrower_id, _("More details"), _("ILL"), nb_ill, CFG_SITE_URL, borrower_id, _("More details"), _("Historical overview"), _("Requests"), nb_req_hist, CFG_SITE_URL, borrower_id, _("More details"), _("Loans"), nb_loans_hist, CFG_SITE_URL, borrower_id, _("More details"), _("ILL"), nb_ill_hist, CFG_SITE_URL, borrower_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 + + title_link = create_html_link(CFG_SITE_URL + '/admin/bibcirculation/bibcirculationadmin.py/get_item_details', {'recid': recid, 'ln': ln}, (book_title_from_MARC(recid))) - out += """ + 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 + '/admin/bibcirculation/bibcirculationadmin.py/get_item_details', {'recid': recid, 'ln': ln}, (book_title_from_MARC(recid))) no_notes_link = create_html_link(CFG_SITE_URL + '/admin/bibcirculation/bibcirculationadmin.py/get_loans_notes', {'loan_id': loan_id, 'recid': recid, 'ln': ln}, (_("No notes"))) see_notes_link = create_html_link(CFG_SITE_URL + '/admin/bibcirculation/bibcirculationadmin.py/get_loans_notes', {'loan_id': loan_id, 'recid': recid, '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 + '/admin/bibcirculation/bibcirculationadmin.py/get_borrower_details', {'borrower_id': borrower_id, 'ln': ln}, (borrower_name)) see_notes_link = create_html_link(CFG_SITE_URL + '/admin/bibcirculation/bibcirculationadmin.py/get_loans_notes', {'loan_id': loan_id, 'recid': recid, 'ln': ln}, (_("see notes"))) no_notes_link = create_html_link(CFG_SITE_URL + '/admin/bibcirculation/bibcirculationadmin.py/get_loans_notes', {'loan_id': loan_id, 'recid': recid, '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 + '/admin/bibcirculation/bibcirculationadmin.py/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 + '/admin/bibcirculation/bibcirculationadmin.py/get_borrower_details', {'borrower_id': borrower_id, 'ln': ln}, (borrower_name)) see_notes_link = create_html_link(CFG_SITE_URL + '/admin/bibcirculation/bibcirculationadmin.py/get_loans_notes', {'loan_id': loan_id, 'recid': recid, 'ln': ln}, (_("see notes"))) no_notes_link = create_html_link(CFG_SITE_URL + '/admin/bibcirculation/bibcirculationadmin.py/get_loans_notes', {'loan_id': loan_id, 'recid': recid, '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 + '/admin/bibcirculation/bibcirculationadmin.py/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 + '/admin/bibcirculation/bibcirculationadmin.py/get_borrower_details', {'borrower_id': borrower_id, 'ln': ln}, (borrower_name)) see_notes_link = create_html_link(CFG_SITE_URL + '/admin/bibcirculation/bibcirculationadmin.py/get_loans_notes', {'loan_id': loan_id, 'recid': recid, 'ln': ln}, (_("see notes"))) no_notes_link = create_html_link(CFG_SITE_URL + '/admin/bibcirculation/bibcirculationadmin.py/get_loans_notes', {'loan_id': loan_id, 'recid': recid, '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 + '/admin/bibcirculation/bibcirculationadmin.py/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 + '/admin/bibcirculation/bibcirculationadmin.py/get_borrower_details', {'borrower_id': borrower_id, 'ln': ln}, (borrower_name)) no_notes_link = create_html_link(CFG_SITE_URL + '/admin/bibcirculation/bibcirculationadmin.py/get_loans_notes', {'loan_id': loan_id, 'recid': recid, 'ln': ln}, (_("No notes"))) see_notes_link = create_html_link(CFG_SITE_URL + '/admin/bibcirculation/bibcirculationadmin.py/get_loans_notes', {'loan_id': loan_id, 'recid': recid, '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_ (borrower_id, name, email, phone, address, mailbox) = borrower out += """

%s
%s %s
%s %s
%s %s
%s %s
%s %s
"""% (CFG_SITE_URL, borrower_id, request_id, _("Personal details"), _("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 + '/admin/bibcirculation/bibcirculationadmin.py/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, - recid, referer, back="", ln=CFG_SITE_LANG): + 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 + '/admin/bibcirculation/bibcirculationadmin.py/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 + '/admin/bibcirculation/bibcirculationadmin.py/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, name, email, phone, address, mailbox) = result out = """ """ out += _MENU_ out += """


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



""" % (CFG_SITE_URL, _("Borrower information"), _("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, type, notes) = tup_infos + (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"), type, + _("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 + '/admin/bibcirculation/bibcirculationadmin.py/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_add_new_copy_step1(self, ln=CFG_SITE_LANG): + def tmpl_add_new_copy_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_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 + '/admin/bibcirculation/bibcirculationadmin.py/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 + '/admin/bibcirculation/bibcirculationadmin.py/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 + '/admin/bibcirculation/bibcirculationadmin.py/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, ln=CFG_SITE_LANG): + 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 + '/admin/bibcirculation/bibcirculationadmin.py/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 + '/admin/bibcirculation/bibcirculationadmin.py/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 + '/admin/bibcirculation/bibcirculationadmin.py/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 + '/admin/bibcirculation/bibcirculationadmin.py/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, 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" % (due_date)), CFG_SITE_URL, borrower_id, _("Back borrower's loans")) 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, name, email, phone, address, mailbox) = borrower out += """

%s
%s %s
%s %s
%s %s
%s %s
%s %s
"""% (CFG_SITE_URL, borrower_id, _("Personal details"), _("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, name, email, phone, address, mailbox) = borrower out += """


"""% (_("Borrower details"), _("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





""" 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], _("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) (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) (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 + '/admin/bibcirculation/bibcirculationadmin.py/get_item_details', {'recid': recid, 'ln': ln}, (book_title_from_MARC(recid))) no_notes_link = create_html_link(CFG_SITE_URL + '/admin/bibcirculation/bibcirculationadmin.py/get_purchase_notes', {'purchase_id': purchase_id}, (_("No notes"))) see_notes_link = create_html_link(CFG_SITE_URL + '/admin/bibcirculation/bibcirculationadmin.py/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 + '/admin/bibcirculation/bibcirculationadmin.py/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"), _("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
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 """ (ccid, name, email, phone, address, mailbox) = user_info.split(',') _ = gettext_set_language(ln) 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"), ccid, _("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 """ (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, name, email, phone, address, mailbox) = user_info _ = gettext_set_language(ln) 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, _("Name"), 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"), borrower_id, _("Name"), name, _("Email"), email, _("Phone"), phone, _("Address"), address, _("Mailbox"), mailbox) out += """
""" % (_("Back"), _("Continue")) return out - (ccid, name, email, phone, address, mailbox) = user_info.split(',') + (_ccid, name, email, phone, address, mailbox) = user_info.split(',') 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)) 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 += """
%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_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"), _("From"), _("To"), _("Option(s)")) - for (ill_request_id, borrower_id, borrower_name, library_id, + for (ill_request_id, _borrower_id, borrower_name, library_id, ill_status, period_from, period_to, book_info) in ill_req: - borrower_link = create_html_link(CFG_SITE_URL + - '/admin/bibcirculation/bibcirculationadmin.py/get_borrower_details', - {'borrower_id': borrower_id, 'ln': ln}, - (borrower_name)) + #borrower_link = create_html_link(CFG_SITE_URL + + # '/admin/bibcirculation/bibcirculationadmin.py/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 = '-' book_info = eval(book_info) try: title_link = create_html_link(CFG_SITE_URL + '/admin/bibcirculation/bibcirculationadmin.py/get_item_details', {'recid': book_info['recid'], 'ln': ln}, (book_title_from_MARC(int(book_info['recid'])))) except KeyError: title_link = book_info['title'] out += """ """ % (borrower_name, title_link, library_name, ill_status, period_from, period_to, CFG_SITE_URL, ill_request_id, str(ill_status), _('select')) out += """
%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_req_details, libraries, ill_status, ill_borrower_request, ln=CFG_SITE_LANG): """ @param ill_request_id: identify the ILL request. Primray 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_borrower_request: borrower's informations @type ill_borrower_request: tuple """ _ = gettext_set_language(ln) out = """ """ out += _MENU_ - (borrower_id, borrower_name, borrower_email, borrower_mailbox, + (_borrower_id, borrower_name, borrower_email, borrower_mailbox, period_from, period_to, book_info, borrower_comments, only_this_edition) = ill_borrower_request #(value, currency) = cost.split() 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, 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(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, ill_request_id, _("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 == 'pending': if not ill_req_details: previous_library_notes = {} else: previous_library_notes = eval(ill_req_details) out += """
%s
%s %s
%s """ % (_("Status"), ill_request_id, ill_request_id, ill_request_id, ill_request_id, ill_request_id, ill_request_id, _("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 + '/admin/bibcirculation/bibcirculationadmin.py/ill_request_details_step1', {'delete_key': key, 'ill_request_id': ill_request_id, 'ill_status': ill_status, 'ln': ln}, (_("[delete]"))) out += """ """ % (key, previous_library_notes[key], delete_note) out += """
%s %s %s
%s
""" % (_("Library notes")) elif ill_status == 'request sent, not yet received': (library_id, request_date, expected_date, cost, barcode, previous_notes) = ill_req_details if not previous_notes: previous_library_notes = {} else: previous_library_notes = eval(previous_notes) if cost: (value, currency) = cost.split() else: (value, currency) = (0, 'EUR') out += """
%s
%s %s
%s
%s select request date
%s select expected date
%s
%s
%s """ %(_("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 + '/admin/bibcirculation/bibcirculationadmin.py/ill_request_details_step1', {'delete_key': key, 'ill_request_id': ill_request_id, 'ill_status': ill_status, 'ln': ln}, (_("[delete]"))) out += """ """ % (key, previous_library_notes[key], delete_note) out += """
%s %s %s
%s
""" % (_("Library notes")) # ill_status: 'request cancelled' elif ill_status == 'request cancelled': (library_id, request_date, expected_date, cost, barcode, previous_notes) = ill_req_details if not previous_notes: previous_library_notes = {} else: previous_library_notes = eval(previous_notes) if cost: (value, currency) = cost.split() else: (value, currency) = (0, 'EUR') 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 """ % (_("Barcoce"), 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 + '/admin/bibcirculation/bibcirculationadmin.py/ill_request_details_step1', {'delete_key': key, 'ill_request_id': ill_request_id, 'ill_status': ill_status, 'ln': ln}, (_("[delete]"))) out += """ """ % (key, previous_library_notes[key], delete_note) out += """
%s %s %s
%s
""" % (_("Library notes")) elif ill_status == 'item received, due date defined': (library_id, request_date, expected_date, arrival_date, due_date, cost, barcode, previous_notes) = ill_req_details if not previous_notes: previous_library_notes = {} else: previous_library_notes = eval(previous_notes) if cost: (value, currency) = cost.split() else: (value, currency) = (0, 'EUR') 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 select arrival date
%s select due date
%s
%s
%s """ % (_("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 + '/admin/bibcirculation/bibcirculationadmin.py/ill_request_details_step1', {'delete_key': key, 'ill_request_id': ill_request_id, 'ill_status': ill_status, 'ln': ln}, (_("[delete]"))) out += """ """ % (key, previous_library_notes[key], delete_note) out += """
%s %s %s
%s
""" % (_("Library notes")) elif ill_status == 'item returned': (library_id, request_date, expected_date, arrival_date, due_date, return_date, cost, barcode, previous_notes) = ill_req_details if not previous_notes: previous_library_notes = {} else: previous_library_notes = eval(previous_notes) if cost: (value, currency) = cost.split() else: (value, currency) = (0, 'EUR') 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 select arrival date
%s
%s %s
%s """ % (_("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 + '/admin/bibcirculation/bibcirculationadmin.py/ill_request_details_step1', {'delete_key': key, 'ill_request_id': ill_request_id, 'ill_status': ill_status, 'ln': ln}, (_("[delete]"))) out += """ """ % (key, previous_library_notes[key], delete_note) out += """
%s %s %s
%s
""" % (_("Library notes")) else: (library_id, request_date, expected_date, arrival_date, due_date, return_date, cost, barcode, previous_notes) = ill_req_details if not previous_notes: previous_library_notes = {} else: previous_library_notes = eval(previous_notes) if cost: (value, currency) = cost.split() else: (value, currency) = (0, 'EUR') if library_id: library_name = db.get_library_name(library_id) else: library_name = '-' out += """ """ % (ill_status, _("Status"), ill_request_id, ill_request_id, 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, _("Arrival date"), arrival_date, _("Due date"), due_date, _("Return date"), return_date, _("Cost"), value, currency, _("Barcode"), barcode) out += """
%s
%s %s
%s %s
%s %s
%s %s
%s %s
%s %s
%s %s
%s %s %s
%s %s
%s """ % (_("Previous notes")) key_array = previous_library_notes.keys() key_array.sort() for key in key_array: - delete_note = create_html_link(CFG_SITE_URL + + delete_note = create_html_link(CFG_SITE_URL + '/admin/bibcirculation/bibcirculationadmin.py/ill_request_details_step1', {'delete_key': key, 'ill_request_id': ill_request_id, 'ill_status': ill_status, 'ln': ln}, (_("[delete]"))) - out += """ + out += """ """ % (key, previous_library_notes[key], delete_note) out += """
%s %s %s
%s
""" % (_("Library notes")) out += """


""" % (_("Back"), _("Continue")) return out def tmpl_ill_request_details_step2(self, ill_req_details, request_info, ill_status, ill_borrower_request, 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_borrower_request: borrower's informations @type ill_borrower_request: tuple """ _ = gettext_set_language(ln) out = """ """ out += _MENU_ - (borrower_id, borrower_name, borrower_email, borrower_mailbox, + (_borrower_id, borrower_name, borrower_email, borrower_mailbox, period_from, period_to, book_info, borrower_comments, only_this_edition) = ill_borrower_request 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 == 'pending': if not ill_req_details: previous_library_notes = {} else: previous_library_notes = eval(ill_req_details) (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 + '/admin/bibcirculation/bibcirculationadmin.py/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 sent, not yet received': if not ill_req_details: previous_library_notes = {} else: previous_library_notes = eval(ill_req_details) (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 + '/admin/bibcirculation/bibcirculationadmin.py/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 + '/admin/bibcirculation/bibcirculationadmin.py/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 + '/admin/bibcirculation/bibcirculationadmin.py/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 + '/admin/bibcirculation/bibcirculationadmin.py/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 + '/admin/bibcirculation/bibcirculationadmin.py/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 select order date
%s select order date
%s """ % (_("Order date"), _("order_date"), order_date, _("jsCal1"), _("order_date"), _("jsCal1"), _("Expected date"), _("expected_date"), expected_date, _("jsCal2"), _("expected_date"), _("jsCal2"), _("Previous notes")) key_array = purchase_notes.keys() key_array.sort() for key in key_array: delete_note = create_html_link(CFG_SITE_URL + '/admin/bibcirculation/bibcirculationadmin.py/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 + '/admin/bibcirculation/bibcirculationadmin.py/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 + '/admin/bibcirculation/bibcirculationadmin.py/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 + '/admin/bibcirculation/bibcirculationadmin.py/get_vendor_notes', {'vendor_id': vendor_id}, (_("No notes"))) see_notes_link = create_html_link(CFG_SITE_URL + '/admin/bibcirculation/bibcirculationadmin.py/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

""" % (_("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
%s select period of interest
%s select period of interest
%s
%s



""" % (_("ILL request details"), _("Period of interest - From"), datetime.date.today().strftime('%Y-%m-%d'), "jsCal1", "period_of_interest_from", "jsCal1", _("Period of interest - To"), (datetime.date.today() + datetime.timedelta(days=365)).strftime('%Y-%m-%d'), "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_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) + #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 """ (title, authors, place, publisher, year, edition, isbn) = book_info - (borrower_id, name, email, phone, address, mailbox) = user_info + (_borrower_id, name, email, phone, address, mailbox) = user_info (period_of_interest_from, period_of_interest_to, additional_comments, only_edition)= request_details _ = gettext_set_language(ln) - out += _MENU_ + out = _MENU_ out += """ -
+

""" % (CFG_SITE_URL, book_info, _("Item details"), _("Name"), 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
""" % (_("Borrower details"), user_info, _("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, ill_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 += """

"""% (_("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 + '/admin/bibcirculation/bibcirculationadmin.py/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 + '/admin/bibcirculation/bibcirculationadmin.py/get_item_details', {'recid': book_info['recid'], 'ln': ln}, (book_title_from_MARC(int(book_info['recid'])))) except KeyError: title_link = book_info['title'] # links to notes pages lib_no_notes_link = create_html_link(CFG_SITE_URL + '/admin/bibcirculation/bibcirculationadmin.py/get_ill_library_notes', {'ill_id': ill_id}, (_("No notes"))) lib_see_notes_link = create_html_link(CFG_SITE_URL + '/admin/bibcirculation/bibcirculationadmin.py/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 += """ """ % (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


""" % (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 + '/admin/bibcirculation/bibcirculationadmin.py/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 + '/admin/bibcirculation/bibcirculationadmin.py/get_item_details', {'recid': recid, 'ln': ln}, (book_title_from_MARC(recid))) if borrower_name: borrower_link = create_html_link(CFG_SITE_URL + '/admin/bibcirculation/bibcirculationadmin.py/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 = """ """ out += _MENU_ if len(result) == 0: - out += """ + out += """

%s

""" % (_("0 item(s) 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 + '/admin/bibcirculation/bibcirculationadmin.py/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_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, borrower_id, ln=CFG_SITE_LANG): + 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 += """ + out += """

%s

""" % (_("0 item(s) 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 + '/admin/bibcirculation/bibcirculationadmin.py/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 """ (title, authors, place, publisher, year, edition, isbn) = book_info - (borrower_id, name, email, phone, address, mailbox) = user_info + (_borrower_id, name, email, phone, address, mailbox) = user_info (period_of_interest_from, period_of_interest_to, additional_comments, only_edition)= request_details _ = gettext_set_language(ln) 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
""" % (CFG_SITE_URL, _("Item details"), book_info, _("Name"), 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, _("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""" + #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 supplier






""" % (CFG_SITE_URL, _("Back"), _("Search")) return out diff --git a/modules/bibcirculation/lib/bibcirculation_webinterface.py b/modules/bibcirculation/lib/bibcirculation_webinterface.py index 86bf014e5..c9a6d8b33 100644 --- a/modules/bibcirculation/lib/bibcirculation_webinterface.py +++ b/modules/bibcirculation/lib/bibcirculation_webinterface.py @@ -1,735 +1,733 @@ # -*- 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 web interface """ __revision__ = "$Id$" __lastupdated__ = """$Date$""" # others invenio imports from invenio.config import CFG_SITE_LANG, \ CFG_SITE_URL, \ CFG_SITE_SECURE_URL, \ CFG_ACCESS_CONTROL_LEVEL_SITE, \ CFG_WEBSESSION_DIFFERENTIATE_BETWEEN_GUESTS from invenio.webuser import getUid, page_not_authorized, isGuestUser, \ collect_user_info from invenio.webpage import page, pageheaderonly, pagefooteronly from invenio.search_engine import create_navtrail_links, \ guess_primary_collection_of_a_record, \ get_colID, check_user_can_view_record from invenio.urlutils import redirect_to_url, \ make_canonical_urlargd from invenio.messages import gettext_set_language from invenio.webinterface_handler import wash_urlargd, WebInterfaceDirectory from invenio.websearchadminlib import get_detailed_page_tabs from invenio.access_control_config import VIEWRESTRCOLL from invenio.access_control_mailcookie import mail_cookie_create_authorize_action import invenio.template webstyle_templates = invenio.template.load('webstyle') websearch_templates = invenio.template.load('websearch') # bibcirculation imports bibcirculation_templates = invenio.template.load('bibcirculation') from invenio.bibcirculation import perform_new_request, \ - perform_new_request_send, \ perform_get_holdings_information, \ perform_borrower_loans, \ perform_loanshistoricaloverview, \ - ill_request_with_recid, \ - ill_register_request_with_recid, \ display_ill_form, \ ill_register_request class WebInterfaceYourLoansPages(WebInterfaceDirectory): """Defines the set of /yourloans pages.""" _exports = ['', 'display', 'loanshistoricaloverview'] - def index(self, req, form): + def index(self, req): """ The function called by default """ redirect_to_url(req, "%s/yourloans/display?%s" % (CFG_SITE_URL, req.args)) def display(self, req, form): """ Displays all loans of a given user @param ln: language @return the page for inbox """ argd = wash_urlargd(form, {'barcode': (str, ""), 'borrower_id': (int, 0), 'request_id': (int, 0)}) # Check if user is logged uid = getUid(req) if CFG_ACCESS_CONTROL_LEVEL_SITE >= 1: return page_not_authorized(req, "%s/yourloans/display" % \ (CFG_SITE_URL,), navmenuid="yourloans") elif uid == -1 or isGuestUser(uid): return redirect_to_url(req, "%s/youraccount/login%s" % ( CFG_SITE_SECURE_URL, make_canonical_urlargd({ 'referer' : "%s/yourloans/display%s" % ( CFG_SITE_URL, make_canonical_urlargd(argd, {})), "ln" : argd['ln']}, {}))) _ = gettext_set_language(argd['ln']) user_info = collect_user_info(req) if not user_info['precached_useloans']: return page_not_authorized(req, "../", \ text = _("You are not authorized to use loans.")) body = perform_borrower_loans(uid=uid, barcode=argd['barcode'], borrower_id=argd['borrower_id'], request_id=argd['request_id'], ln=argd['ln']) return page(title = _("Your Loans"), body = body, uid = uid, lastupdated = __lastupdated__, req = req, language = argd['ln'], navmenuid = "yourloans") def loanshistoricaloverview(self, req, form): """ Show loans historical overview. """ argd = wash_urlargd(form, {}) # Check if user is logged uid = getUid(req) if CFG_ACCESS_CONTROL_LEVEL_SITE >= 1: return page_not_authorized(req, "%s/yourloans/loanshistoricaloverview" % \ (CFG_SITE_URL,), navmenuid="yourloans") elif uid == -1 or isGuestUser(uid): return redirect_to_url(req, "%s/youraccount/login%s" % ( CFG_SITE_SECURE_URL, make_canonical_urlargd({ 'referer' : "%s/yourloans/loanshistoricaloverview%s" % ( CFG_SITE_URL, make_canonical_urlargd(argd, {})), "ln" : argd['ln']}, {}))) _ = gettext_set_language(argd['ln']) user_info = collect_user_info(req) if not user_info['precached_useloans']: return page_not_authorized(req, "../", \ text = _("You are not authorized to use loans.")) body = perform_loanshistoricaloverview(uid=uid, ln=argd['ln']) return page(title = _("Loans - historical overview"), body = body, uid = uid, lastupdated = __lastupdated__, req = req, language = argd['ln'], navmenuid = "yourloans") class WebInterfaceILLPages(WebInterfaceDirectory): """Defines the set of /ill pages.""" _exports = ['', 'display', 'register_request'] - def index(self, req, form): + def index(self, req): """ The function called by default """ redirect_to_url(req, "%s/ill/display?%s" % (CFG_SITE_URL, req.args)) def display(self, req, form): """ Displays all loans of a given user @param ln: language @return the page for inbox """ argd = wash_urlargd(form, {}) # Check if user is logged uid = getUid(req) if CFG_ACCESS_CONTROL_LEVEL_SITE >= 1: return page_not_authorized(req, "%s/ill/display" % \ (CFG_SITE_URL,), navmenuid="ill") elif uid == -1 or isGuestUser(uid): return redirect_to_url(req, "%s/youraccount/login%s" % ( CFG_SITE_SECURE_URL, make_canonical_urlargd({ 'referer' : "%s/ill/display%s" % ( CFG_SITE_URL, make_canonical_urlargd(argd, {})), "ln" : argd['ln']}, {}))) _ = gettext_set_language(argd['ln']) user_info = collect_user_info(req) if not user_info['precached_useloans']: return page_not_authorized(req, "../", \ text = _("You are not authorized to use ill.")) body = display_ill_form(uid=uid, ln=argd['ln']) return page(title = _("Interlibrary loan request for books"), body = body, uid = uid, lastupdated = __lastupdated__, req = req, language = argd['ln'], navmenuid = "ill") def register_request(self, req, form): """ Displays all loans of a given user @param ln: language @return the page for inbox """ argd = wash_urlargd(form, {'ln': (str, ""), 'title': (str, ""), 'authors': (str, ""), 'place': (str, ""), 'publisher': (str, ""), 'year': (str, ""), 'edition': (str, ""), 'isbn': (str, ""), 'period_of_interest_from': (str, ""), 'period_of_interest_to': (str, ""), 'additional_comments': (str, ""), 'conditions': (str, ""), 'only_edition': (str, ""), }) # Check if user is logged uid = getUid(req) if CFG_ACCESS_CONTROL_LEVEL_SITE >= 1: return page_not_authorized(req, "%s/ill/register_request" % \ (CFG_SITE_URL,), navmenuid="ill") elif uid == -1 or isGuestUser(uid): return redirect_to_url(req, "%s/youraccount/login%s" % ( CFG_SITE_SECURE_URL, make_canonical_urlargd({ 'referer' : "%s/ill/register_request%s" % ( CFG_SITE_URL, make_canonical_urlargd(argd, {})), "ln" : argd['ln']}, {}))) _ = gettext_set_language(argd['ln']) user_info = collect_user_info(req) if not user_info['precached_useloans']: return page_not_authorized(req, "../", \ text = _("You are not authorized to use ill.")) body = ill_register_request(uid=uid, title=argd['title'], authors=argd['authors'], place=argd['place'], publisher=argd['publisher'], year=argd['year'], edition=argd['edition'], isbn=argd['isbn'], period_of_interest_from = argd['period_of_interest_from'], period_of_interest_to = argd['period_of_interest_to'], additional_comments = argd['additional_comments'], conditions = argd['conditions'], only_edition = argd['only_edition'], ln=argd['ln']) return page(title = _("Interlibrary loan request for books"), body = body, uid = uid, lastupdated = __lastupdated__, req = req, language = argd['ln'], navmenuid = "ill") class WebInterfaceHoldingsPages(WebInterfaceDirectory): """Defines the set of /holdings pages.""" _exports = ['', 'display', 'request', 'send', 'ill_request_with_recid', 'ill_register_request_with_recid'] def __init__(self, recid=-1): self.recid = recid def index(self, req, form): """ Redirects to display function """ return self.display(req, form) def display(self, req, form): """ Show the tab 'holdings'. """ argd = wash_urlargd(form, {'do': (str, "od"), 'ds': (str, "all"), 'nb': (int, 100), 'p': (int, 1), 'voted': (int, -1), 'reported': (int, -1), }) body = perform_get_holdings_information(self.recid, req, argd['ln']) _ = gettext_set_language(argd['ln']) uid = getUid(req) user_info = collect_user_info(req) (auth_code, auth_msg) = check_user_can_view_record(user_info, self.recid) if auth_code and user_info['email'] == 'guest' and not user_info['apache_user']: cookie = mail_cookie_create_authorize_action(VIEWRESTRCOLL, {'collection' : guess_primary_collection_of_a_record(self.recid)}) target = '/youraccount/login' + \ make_canonical_urlargd({'action': cookie, 'ln' : argd['ln'], 'referer' : \ CFG_SITE_URL + user_info['uri']}, {}) return redirect_to_url(req, target) elif auth_code: return page_not_authorized(req, "../", \ text = auth_msg) unordered_tabs = get_detailed_page_tabs(get_colID(guess_primary_collection_of_a_record(self.recid)), self.recid, ln=argd['ln']) ordered_tabs_id = [(tab_id, values['order']) for (tab_id, values) in unordered_tabs.iteritems()] ordered_tabs_id.sort(lambda x, y: cmp(x[1], y[1])) link_ln = '' if argd['ln'] != CFG_SITE_LANG: link_ln = '?ln=%s' % argd['ln'] tabs = [(unordered_tabs[tab_id]['label'], \ '%s/record/%s/%s%s' % (CFG_SITE_URL, self.recid, tab_id, link_ln), \ tab_id in ['holdings'], unordered_tabs[tab_id]['enabled']) \ for (tab_id, _order) in ordered_tabs_id if unordered_tabs[tab_id]['visible'] == True] top = webstyle_templates.detailed_record_container_top(self.recid, tabs, argd['ln']) bottom = webstyle_templates.detailed_record_container_bottom(self.recid, tabs, argd['ln']) title = websearch_templates.tmpl_record_page_header_content(req, self.recid, argd['ln'])[0] navtrail = create_navtrail_links(cc=guess_primary_collection_of_a_record(self.recid), ln=argd['ln']) navtrail += ' > '% (CFG_SITE_URL, self.recid, argd['ln']) navtrail += title navtrail += '' return pageheaderonly(title=title, navtrail=navtrail, uid=uid, verbose=1, req=req, language=argd['ln'], navmenuid='search', navtrail_append_title_p=0) + \ websearch_templates.tmpl_search_pagestart(argd['ln']) + \ top + body + bottom + \ websearch_templates.tmpl_search_pageend(argd['ln']) + \ pagefooteronly(lastupdated=__lastupdated__, language=argd['ln'], req=req) # Return the same page wether we ask for /record/123 or /record/123/ __call__ = index def request(self, req, form): """ Show new hold request form. """ argd = wash_urlargd(form, {'ln': (str, ""), 'barcode': (str, "")}) _ = gettext_set_language(argd['ln']) uid = getUid(req) body = perform_new_request(recid=self.recid, uid=uid, barcode=argd['barcode'], ln=argd['ln']) uid = getUid(req) if uid == -1 or CFG_ACCESS_CONTROL_LEVEL_SITE >= 1: return page_not_authorized(req, "../holdings/request", navmenuid = 'yourbaskets') if isGuestUser(uid): if not CFG_WEBSESSION_DIFFERENTIATE_BETWEEN_GUESTS: return redirect_to_url(req, "%s/youraccount/login%s" % ( CFG_SITE_SECURE_URL, make_canonical_urlargd({ 'referer' : "%s/record/%s/holdings/request%s" % ( CFG_SITE_URL, self.recid, make_canonical_urlargd(argd, {})), "ln" : argd['ln']}, {}))) user_info = collect_user_info(req) (auth_code, auth_msg) = check_user_can_view_record(user_info, self.recid) if auth_code and user_info['email'] == 'guest' and not user_info['apache_user']: cookie = mail_cookie_create_authorize_action(VIEWRESTRCOLL, {'collection' : guess_primary_collection_of_a_record(self.recid)}) target = '/youraccount/login' + \ make_canonical_urlargd({'action': cookie, 'ln' : argd['ln'], 'referer' : \ CFG_SITE_URL + user_info['uri']}, {}) return redirect_to_url(req, target) elif auth_code: return page_not_authorized(req, "../", \ text = auth_msg) unordered_tabs = get_detailed_page_tabs(get_colID(guess_primary_collection_of_a_record(self.recid)), self.recid, ln=argd['ln']) ordered_tabs_id = [(tab_id, values['order']) for (tab_id, values) in unordered_tabs.iteritems()] ordered_tabs_id.sort(lambda x, y: cmp(x[1], y[1])) link_ln = '' if argd['ln'] != CFG_SITE_LANG: link_ln = '?ln=%s' % argd['ln'] tabs = [(unordered_tabs[tab_id]['label'], \ '%s/record/%s/%s%s' % (CFG_SITE_URL, self.recid, tab_id, link_ln), \ tab_id in ['holdings'], unordered_tabs[tab_id]['enabled']) \ for (tab_id, _order) in ordered_tabs_id if unordered_tabs[tab_id]['visible'] == True] top = webstyle_templates.detailed_record_container_top(self.recid, tabs, argd['ln']) bottom = webstyle_templates.detailed_record_container_bottom(self.recid, tabs, argd['ln']) title = websearch_templates.tmpl_record_page_header_content(req, self.recid, argd['ln'])[0] navtrail = create_navtrail_links(cc=guess_primary_collection_of_a_record(self.recid), ln=argd['ln']) navtrail += ' > '% (CFG_SITE_URL, self.recid, argd['ln']) navtrail += title navtrail += '' return pageheaderonly(title=title, navtrail=navtrail, uid=uid, verbose=1, req=req, language=argd['ln'], navmenuid='search', navtrail_append_title_p=0) + \ websearch_templates.tmpl_search_pagestart(argd['ln']) + \ top + body + bottom + \ websearch_templates.tmpl_search_pageend(argd['ln']) + \ pagefooteronly(lastupdated=__lastupdated__, language=argd['ln'], req=req) - - - def send(self, req, form): - """ - Create a new hold request. - """ - argd = wash_urlargd(form, {'period_from': (str, ""), - 'period_to': (str, ""), - 'barcode': (str, "") - }) - - - uid = getUid(req) - - body = perform_new_request_send(recid=self.recid, - uid=uid, - period_from=argd['period_from'], - period_to=argd['period_to'], - barcode=argd['barcode'], - ln=argd['ln']) - - - - _ = gettext_set_language(argd['ln']) - - - user_info = collect_user_info(req) - (auth_code, auth_msg) = check_user_can_view_record(user_info, self.recid) - if auth_code and user_info['email'] == 'guest' and not user_info['apache_user']: - cookie = mail_cookie_create_authorize_action(VIEWRESTRCOLL, {'collection' : guess_primary_collection_of_a_record(self.recid)}) - target = '/youraccount/login' + \ - make_canonical_urlargd({'action': cookie, 'ln' : argd['ln'], 'referer' : \ - CFG_SITE_URL + user_info['uri']}, {}) - return redirect_to_url(req, target) - elif auth_code: - return page_not_authorized(req, "../", \ - text = auth_msg) - - - - unordered_tabs = get_detailed_page_tabs(get_colID(guess_primary_collection_of_a_record(self.recid)), - self.recid, - ln=argd['ln']) - ordered_tabs_id = [(tab_id, values['order']) for (tab_id, values) in unordered_tabs.iteritems()] - ordered_tabs_id.sort(lambda x, y: cmp(x[1], y[1])) - link_ln = '' - if argd['ln'] != CFG_SITE_LANG: - link_ln = '?ln=%s' % argd['ln'] - tabs = [(unordered_tabs[tab_id]['label'], \ - '%s/record/%s/%s%s' % (CFG_SITE_URL, self.recid, tab_id, link_ln), \ - tab_id in ['holdings'], - unordered_tabs[tab_id]['enabled']) \ - for (tab_id, _order) in ordered_tabs_id - if unordered_tabs[tab_id]['visible'] == True] - top = webstyle_templates.detailed_record_container_top(self.recid, - tabs, - argd['ln']) - bottom = webstyle_templates.detailed_record_container_bottom(self.recid, - tabs, - argd['ln']) - - title = websearch_templates.tmpl_record_page_header_content(req, self.recid, argd['ln'])[0] - navtrail = create_navtrail_links(cc=guess_primary_collection_of_a_record(self.recid), ln=argd['ln']) - navtrail += ' > '% (CFG_SITE_URL, self.recid, argd['ln']) - navtrail += title - navtrail += '' - - return pageheaderonly(title=title, - navtrail=navtrail, - uid=uid, - verbose=1, - req=req, - language=argd['ln'], - navmenuid='search', - navtrail_append_title_p=0) + \ - websearch_templates.tmpl_search_pagestart(argd['ln']) + \ - top + body + bottom + \ - websearch_templates.tmpl_search_pageend(argd['ln']) + \ - pagefooteronly(lastupdated=__lastupdated__, - language=argd['ln'], req=req) - - - - - - - def ill_request_with_recid(self, req, form): - """ - Show ILL request form. - """ - - - argd = wash_urlargd(form, {'ln': (str, "")}) - - _ = gettext_set_language(argd['ln']) - uid = getUid(req) - - body = ill_request_with_recid(recid=self.recid, - uid=uid, - ln=argd['ln']) - - uid = getUid(req) - if uid == -1 or CFG_ACCESS_CONTROL_LEVEL_SITE >= 1: - return page_not_authorized(req, "../holdings/ill_request_with_recid", - navmenuid = 'yourbaskets') - - if isGuestUser(uid): - if not CFG_WEBSESSION_DIFFERENTIATE_BETWEEN_GUESTS: - return redirect_to_url(req, "%s/youraccount/login%s" % ( - CFG_SITE_SECURE_URL, - make_canonical_urlargd({ - 'referer' : "%s/record/%s/holdings/ill_request_with_recid%s" % ( - CFG_SITE_URL, - self.recid, - make_canonical_urlargd(argd, {})), - "ln" : argd['ln']}, {}))) - - - user_info = collect_user_info(req) - (auth_code, auth_msg) = check_user_can_view_record(user_info, self.recid) - if auth_code and user_info['email'] == 'guest' and not user_info['apache_user']: - cookie = mail_cookie_create_authorize_action(VIEWRESTRCOLL, {'collection' : guess_primary_collection_of_a_record(self.recid)}) - target = '/youraccount/login' + \ - make_canonical_urlargd({'action': cookie, 'ln' : argd['ln'], 'referer' : \ - CFG_SITE_URL + user_info['uri']}, {}) - return redirect_to_url(req, target) - elif auth_code: - return page_not_authorized(req, "../", \ - text = auth_msg) - - - - unordered_tabs = get_detailed_page_tabs(get_colID(guess_primary_collection_of_a_record(self.recid)), - self.recid, - ln=argd['ln']) - ordered_tabs_id = [(tab_id, values['order']) for (tab_id, values) in unordered_tabs.iteritems()] - ordered_tabs_id.sort(lambda x, y: cmp(x[1], y[1])) - link_ln = '' - if argd['ln'] != CFG_SITE_LANG: - link_ln = '?ln=%s' % argd['ln'] - tabs = [(unordered_tabs[tab_id]['label'], \ - '%s/record/%s/%s%s' % (CFG_SITE_URL, self.recid, tab_id, link_ln), \ - tab_id in ['holdings'], - unordered_tabs[tab_id]['enabled']) \ - for (tab_id, _order) in ordered_tabs_id - if unordered_tabs[tab_id]['visible'] == True] - top = webstyle_templates.detailed_record_container_top(self.recid, - tabs, - argd['ln']) - bottom = webstyle_templates.detailed_record_container_bottom(self.recid, - tabs, - argd['ln']) - - title = websearch_templates.tmpl_record_page_header_content(req, self.recid, argd['ln'])[0] - navtrail = create_navtrail_links(cc=guess_primary_collection_of_a_record(self.recid), ln=argd['ln']) - navtrail += ' > '% (CFG_SITE_URL, self.recid, argd['ln']) - navtrail += title - navtrail += '' - - return pageheaderonly(title=title, - navtrail=navtrail, - uid=uid, - verbose=1, - req=req, - language=argd['ln'], - navmenuid='search', - navtrail_append_title_p=0) + \ - websearch_templates.tmpl_search_pagestart(argd['ln']) + \ - top + body + bottom + \ - websearch_templates.tmpl_search_pageend(argd['ln']) + \ - pagefooteronly(lastupdated=__lastupdated__, language=argd['ln'], req=req) - - - def ill_register_request_with_recid(self, req, form): - """ - Register ILL request. - """ - - argd = wash_urlargd(form, {'ln': (str, ""), - 'period_of_interest_from': (str, ""), - 'period_of_interest_to': (str, ""), - 'additional_comments': (str, ""), - 'conditions': (str, ""), - 'only_edition': (str, ""), - }) - - _ = gettext_set_language(argd['ln']) - uid = getUid(req) - - body = ill_register_request_with_recid(recid=self.recid, - uid=uid, - period_of_interest_from = argd['period_of_interest_from'], - period_of_interest_to = argd['period_of_interest_to'], - additional_comments = argd['additional_comments'], - conditions = argd['conditions'], - only_edition = argd['only_edition'], - ln=argd['ln']) - - uid = getUid(req) - if uid == -1 or CFG_ACCESS_CONTROL_LEVEL_SITE >= 1: - return page_not_authorized(req, "../holdings/ill_request_with_recid", - navmenuid = 'yourbaskets') - - if isGuestUser(uid): - if not CFG_WEBSESSION_DIFFERENTIATE_BETWEEN_GUESTS: - return redirect_to_url(req, "%s/youraccount/login%s" % ( - CFG_SITE_SECURE_URL, - make_canonical_urlargd({ - 'referer' : "%s/record/%s/holdings/ill_request_with_recid%s" % ( - CFG_SITE_URL, - self.recid, - make_canonical_urlargd(argd, {})), - "ln" : argd['ln']}, {}))) - - - user_info = collect_user_info(req) - (auth_code, auth_msg) = check_user_can_view_record(user_info, self.recid) - if auth_code and user_info['email'] == 'guest' and not user_info['apache_user']: - cookie = mail_cookie_create_authorize_action(VIEWRESTRCOLL, {'collection' : guess_primary_collection_of_a_record(self.recid)}) - target = '/youraccount/login' + \ - make_canonical_urlargd({'action': cookie, 'ln' : argd['ln'], 'referer' : \ - CFG_SITE_URL + user_info['uri']}, {}) - return redirect_to_url(req, target) - elif auth_code: - return page_not_authorized(req, "../", \ - text = auth_msg) - - - - unordered_tabs = get_detailed_page_tabs(get_colID(guess_primary_collection_of_a_record(self.recid)), - self.recid, - ln=argd['ln']) - ordered_tabs_id = [(tab_id, values['order']) for (tab_id, values) in unordered_tabs.iteritems()] - ordered_tabs_id.sort(lambda x, y: cmp(x[1], y[1])) - link_ln = '' - if argd['ln'] != CFG_SITE_LANG: - link_ln = '?ln=%s' % argd['ln'] - tabs = [(unordered_tabs[tab_id]['label'], \ - '%s/record/%s/%s%s' % (CFG_SITE_URL, self.recid, tab_id, link_ln), \ - tab_id in ['holdings'], - unordered_tabs[tab_id]['enabled']) \ - for (tab_id, _order) in ordered_tabs_id - if unordered_tabs[tab_id]['visible'] == True] - top = webstyle_templates.detailed_record_container_top(self.recid, - tabs, - argd['ln']) - bottom = webstyle_templates.detailed_record_container_bottom(self.recid, - tabs, - argd['ln']) - - title = websearch_templates.tmpl_record_page_header_content(req, self.recid, argd['ln'])[0] - navtrail = create_navtrail_links(cc=guess_primary_collection_of_a_record(self.recid), ln=argd['ln']) - navtrail += ' > '% (CFG_SITE_URL, self.recid, argd['ln']) - navtrail += title - navtrail += '' - - return pageheaderonly(title=title, - navtrail=navtrail, - uid=uid, - verbose=1, - req=req, - language=argd['ln'], - navmenuid='search', - navtrail_append_title_p=0) + \ - websearch_templates.tmpl_search_pagestart(argd['ln']) + \ - top + body + bottom + \ - websearch_templates.tmpl_search_pageend(argd['ln']) + \ - pagefooteronly(lastupdated=__lastupdated__, language=argd['ln'], req=req) + #def send(self, req, form): + # """ + # Create a new hold request. + # """ + # argd = wash_urlargd(form, {'period_from': (str, ""), + # 'period_to': (str, ""), + # 'barcode': (str, "") + # }) + # + # + # uid = getUid(req) + # + # body = perform_new_request_send(recid=self.recid, + # uid=uid, + # period_from=argd['period_from'], + # period_to=argd['period_to'], + # barcode=argd['barcode'], + # ln=argd['ln']) + # + #def perform_new_request_send(self, uid, recid, + # from_year, from_month, from_day, + # to_year, to_month, to_day, + # barcode, ln=CFG_SITE_LANG): + # + # _ = gettext_set_language(ln) + # + # + # user_info = collect_user_info(req) + # (auth_code, auth_msg) = check_user_can_view_record(user_info, self.recid) + # if auth_code and user_info['email'] == 'guest' and not user_info['apache_user']: + # cookie = mail_cookie_create_authorize_action(VIEWRESTRCOLL, {'collection' : guess_primary_collection_of_a_record(self.recid)}) + # target = '/youraccount/login' + \ + # make_canonical_urlargd({'action': cookie, 'ln' : argd['ln'], 'referer' : \ + # CFG_SITE_URL + user_info['uri']}, {}) + # return redirect_to_url(req, target) + # elif auth_code: + # return page_not_authorized(req, "../", \ + # text = auth_msg) + # + # + # + # unordered_tabs = get_detailed_page_tabs(get_colID(guess_primary_collection_of_a_record(self.recid)), + # self.recid, + # ln='ln') + # ordered_tabs_id = [(tab_id, values['order']) for (tab_id, values) in unordered_tabs.iteritems()] + # ordered_tabs_id.sort(lambda x, y: cmp(x[1], y[1])) + # link_ln = '' + # if argd['ln'] != CFG_SITE_LANG: + # link_ln = '?ln=%s' % ln + # tabs = [(unordered_tabs[tab_id]['label'], \ + # '%s/record/%s/%s%s' % (CFG_SITE_URL, self.recid, tab_id, link_ln), \ + # tab_id in ['holdings'], + # unordered_tabs[tab_id]['enabled']) \ + # for (tab_id, _order) in ordered_tabs_id + # if unordered_tabs[tab_id]['visible'] == True] + # top = webstyle_templates.detailed_record_container_top(self.recid, + # tabs, + # argd['ln']) + # bottom = webstyle_templates.detailed_record_container_bottom(self.recid, + # tabs, + # argd['ln']) + # + # title = websearch_templates.tmpl_record_page_header_content(req, self.recid, argd['ln'])[0] + # navtrail = create_navtrail_links(cc=guess_primary_collection_of_a_record(self.recid), ln=argd['ln']) + # navtrail += ' > '% (CFG_SITE_URL, self.recid, argd['ln']) + # navtrail += title + # navtrail += '' + # + # return pageheaderonly(title=title, + # navtrail=navtrail, + # uid=uid, + # verbose=1, + # req=req, + # language=argd['ln'], + # navmenuid='search', + # navtrail_append_title_p=0) + \ + # websearch_templates.tmpl_search_pagestart(argd['ln']) + \ + # top + body + bottom + \ + # websearch_templates.tmpl_search_pageend(argd['ln']) + \ + # pagefooteronly(lastupdated=__lastupdated__, + # language=argd['ln'], req=req) + + + + + + # + #def ill_request_with_recid(self, req, form): + # """ + # Show ILL request form. + # """ + # + # + # argd = wash_urlargd(form, {'ln': (str, "")}) + # + # _ = gettext_set_language(argd['ln']) + # uid = getUid(req) + # + # body = ill_request_with_recid(recid=self.recid, + # uid=uid, + # ln=argd['ln']) + # + # uid = getUid(req) + # if uid == -1 or CFG_ACCESS_CONTROL_LEVEL_SITE >= 1: + # return page_not_authorized(req, "../holdings/ill_request_with_recid", + # navmenuid = 'yourbaskets') + # + # if isGuestUser(uid): + # if not CFG_WEBSESSION_DIFFERENTIATE_BETWEEN_GUESTS: + # return redirect_to_url(req, "%s/youraccount/login%s" % ( + # CFG_SITE_SECURE_URL, + # make_canonical_urlargd({ + # 'referer' : "%s/record/%s/holdings/ill_request_with_recid%s" % ( + # CFG_SITE_URL, + # self.recid, + # make_canonical_urlargd(argd, {})), + # "ln" : argd['ln']}, {}))) + # + # + # user_info = collect_user_info(req) + # (auth_code, auth_msg) = check_user_can_view_record(user_info, self.recid) + # if auth_code and user_info['email'] == 'guest' and not user_info['apache_user']: + # cookie = mail_cookie_create_authorize_action(VIEWRESTRCOLL, {'collection' : guess_primary_collection_of_a_record(self.recid)}) + # target = '/youraccount/login' + \ + # make_canonical_urlargd({'action': cookie, 'ln' : argd['ln'], 'referer' : \ + # CFG_SITE_URL + user_info['uri']}, {}) + # return redirect_to_url(req, target) + # elif auth_code: + # return page_not_authorized(req, "../", \ + # text = auth_msg) + # + # + # + # unordered_tabs = get_detailed_page_tabs(get_colID(guess_primary_collection_of_a_record(self.recid)), + # self.recid, + # ln=argd['ln']) + # ordered_tabs_id = [(tab_id, values['order']) for (tab_id, values) in unordered_tabs.iteritems()] + # ordered_tabs_id.sort(lambda x, y: cmp(x[1], y[1])) + # link_ln = '' + # if argd['ln'] != CFG_SITE_LANG: + # link_ln = '?ln=%s' % argd['ln'] + # tabs = [(unordered_tabs[tab_id]['label'], \ + # '%s/record/%s/%s%s' % (CFG_SITE_URL, self.recid, tab_id, link_ln), \ + # tab_id in ['holdings'], + # unordered_tabs[tab_id]['enabled']) \ + # for (tab_id, _order) in ordered_tabs_id + # if unordered_tabs[tab_id]['visible'] == True] + # top = webstyle_templates.detailed_record_container_top(self.recid, + # tabs, + # argd['ln']) + # bottom = webstyle_templates.detailed_record_container_bottom(self.recid, + # tabs, + # argd['ln']) + # + # title = websearch_templates.tmpl_record_page_header_content(req, self.recid, argd['ln'])[0] + # navtrail = create_navtrail_links(cc=guess_primary_collection_of_a_record(self.recid), ln=argd['ln']) + # navtrail += ' > '% (CFG_SITE_URL, self.recid, argd['ln']) + # navtrail += title + # navtrail += '' + # + # return pageheaderonly(title=title, + # navtrail=navtrail, + # uid=uid, + # verbose=1, + # req=req, + # language=argd['ln'], + # navmenuid='search', + # navtrail_append_title_p=0) + \ + # websearch_templates.tmpl_search_pagestart(argd['ln']) + \ + # top + body + bottom + \ + # websearch_templates.tmpl_search_pageend(argd['ln']) + \ + # pagefooteronly(lastupdated=__lastupdated__, language=argd['ln'], req=req) + # + # + #def ill_register_request_with_recid(self, req, form): + # """ + # Register ILL request. + # """ + # + # argd = wash_urlargd(form, {'ln': (str, ""), + # 'period_of_interest_from': (str, ""), + # 'period_of_interest_to': (str, ""), + # 'additional_comments': (str, ""), + # 'conditions': (str, ""), + # 'only_edition': (str, ""), + # }) + # + # _ = gettext_set_language(argd['ln']) + # uid = getUid(req) + # + # body = ill_register_request_with_recid(recid=self.recid, + # uid=uid, + # period_of_interest_from = argd['period_of_interest_from'], + # period_of_interest_to = argd['period_of_interest_to'], + # additional_comments = argd['additional_comments'], + # conditions = argd['conditions'], + # only_edition = argd['only_edition'], + # ln=argd['ln']) + # + # uid = getUid(req) + # if uid == -1 or CFG_ACCESS_CONTROL_LEVEL_SITE >= 1: + # return page_not_authorized(req, "../holdings/ill_request_with_recid", + # navmenuid = 'yourbaskets') + # + # if isGuestUser(uid): + # if not CFG_WEBSESSION_DIFFERENTIATE_BETWEEN_GUESTS: + # return redirect_to_url(req, "%s/youraccount/login%s" % ( + # CFG_SITE_SECURE_URL, + # make_canonical_urlargd({ + # 'referer' : "%s/record/%s/holdings/ill_request_with_recid%s" % ( + # CFG_SITE_URL, + # self.recid, + # make_canonical_urlargd(argd, {})), + # "ln" : argd['ln']}, {}))) + # + # + # user_info = collect_user_info(req) + # (auth_code, auth_msg) = check_user_can_view_record(user_info, self.recid) + # if auth_code and user_info['email'] == 'guest' and not user_info['apache_user']: + # cookie = mail_cookie_create_authorize_action(VIEWRESTRCOLL, {'collection' : guess_primary_collection_of_a_record(self.recid)}) + # target = '/youraccount/login' + \ + # make_canonical_urlargd({'action': cookie, 'ln' : argd['ln'], 'referer' : \ + # CFG_SITE_URL + user_info['uri']}, {}) + # return redirect_to_url(req, target) + # elif auth_code: + # return page_not_authorized(req, "../", \ + # text = auth_msg) + # + # + # + # unordered_tabs = get_detailed_page_tabs(get_colID(guess_primary_collection_of_a_record(self.recid)), + # self.recid, + # ln=argd['ln']) + # ordered_tabs_id = [(tab_id, values['order']) for (tab_id, values) in unordered_tabs.iteritems()] + # ordered_tabs_id.sort(lambda x, y: cmp(x[1], y[1])) + # link_ln = '' + # if argd['ln'] != CFG_SITE_LANG: + # link_ln = '?ln=%s' % argd['ln'] + # tabs = [(unordered_tabs[tab_id]['label'], \ + # '%s/record/%s/%s%s' % (CFG_SITE_URL, self.recid, tab_id, link_ln), \ + # tab_id in ['holdings'], + # unordered_tabs[tab_id]['enabled']) \ + # for (tab_id, _order) in ordered_tabs_id + # if unordered_tabs[tab_id]['visible'] == True] + # top = webstyle_templates.detailed_record_container_top(self.recid, + # tabs, + # argd['ln']) + # bottom = webstyle_templates.detailed_record_container_bottom(self.recid, + # tabs, + # argd['ln']) + # + # title = websearch_templates.tmpl_record_page_header_content(req, self.recid, argd['ln'])[0] + # navtrail = create_navtrail_links(cc=guess_primary_collection_of_a_record(self.recid), ln=argd['ln']) + # navtrail += ' > '% (CFG_SITE_URL, self.recid, argd['ln']) + # navtrail += title + # navtrail += '' + # + # return pageheaderonly(title=title, + # navtrail=navtrail, + # uid=uid, + # verbose=1, + # req=req, + # language=argd['ln'], + # navmenuid='search', + # navtrail_append_title_p=0) + \ + # websearch_templates.tmpl_search_pagestart(argd['ln']) + \ + # top + body + bottom + \ + # websearch_templates.tmpl_search_pageend(argd['ln']) + \ + # pagefooteronly(lastupdated=__lastupdated__, language=argd['ln'], req=req) diff --git a/modules/bibcirculation/lib/bibcirculationadminlib.py b/modules/bibcirculation/lib/bibcirculationadminlib.py index 91c6fa85b..28ac7e32b 100644 --- a/modules/bibcirculation/lib/bibcirculationadminlib.py +++ b/modules/bibcirculation/lib/bibcirculationadminlib.py @@ -1,6156 +1,6155 @@ # 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 -from math import ceil # 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, \ get_list_of_ILL_requests, \ generate_email_body # Bibcirculation imports from invenio.bibcirculation_config import \ CFG_BIBCIRCULATION_TEMPLATES, CFG_BIBCIRCULATION_AMAZON_ACCESS_KEY, \ CFG_BIBCIRCULATION_LIBRARIAN_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 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 is 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) return page(title="Borrower Search", 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 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_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. """ - infos = [] - if string == '': empty_barcode = 'Empty string. Please, try again.' return borrower_search(req, empty_barcode, ln) if CFG_CERN_SITE == 1: if column == 'name': result = db.search_borrower_by_name(string) elif column == 'email': result = db.search_borrower_by_email(string) else: from invenio.bibcirculation_cern_ldap import get_user_info_from_ldap ldap_info = get_user_info_from_ldap(ccid=string) try: mail = ldap_info['mail'][0] except KeyError: mail = None if mail: result = db.search_borrower_by_email(mail) else: result = () else: if column == 'name': result = db.search_borrower_by_name(string) elif column == 'email': result = db.search_borrower_by_email(string) else: result = db.search_borrower_by_id(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, 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, 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. """ 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) 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, name, email, phone, address, mailbox) in result: tup = (borrower_id, 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, name, email, phone, address, mailbox) in result: tup = (borrower_id, 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, name, email, phone, address, mailbox) in result: tup = (borrower_id, name, email, phone, address, mailbox) list_infos.append(tup) if len(result) == 0 and key: infos.append("0 borrowers found.") if len(result) == 1: return loan_on_desk_step2(req, tup, ln) else: 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 = [] (_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(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/admin/bibcirculation/bibcirculationadmin.py/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) + #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) 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 + '/admin/bibcirculation/bibcirculationadmin.py/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 + '/admin/bibcirculation/bibcirculationadmin.py/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 + '/admin/bibcirculation/bibcirculationadmin.py/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 + '/admin/bibcirculation/bibcirculationadmin.py/get_item_loans_details', {'barcode': barcode, 'loan_id': loan_id, 'force': 'true', 'recid': recid}, ("Yes")) no_renew_link = create_html_link(CFG_SITE_URL + '/admin/bibcirculation/bibcirculationadmin.py/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. """ 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) 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_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, recid, delete_key, +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, - recid=recid, referer=referer, back=back, + 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, recid, borrower_id, add_notes, new_note, ln=CFG_SITE_LANG): +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, - recid=recid, 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, - type, notes, ln=CFG_SITE_LANG): + lib_type, notes, ln=CFG_SITE_LANG): """ Add a new Library. """ - tup_infos = (name, email, phone, address, type, notes) + 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, type, notes) = tup_infos - db.add_new_library(name, email, phone, address, type, notes) + (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 add_new_copy_step1(req, ln=CFG_SITE_LANG): +def add_new_copy_step1(req): """ Add a nex 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(ln=ln) + 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) + #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, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def change_due_date_step2(req, 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, 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(due_date=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) + #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 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, name, email, phone, address, mailbox) in result: tup = (borrower_id, 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, name, email, phone, address, mailbox) in result: tup = (borrower_id, 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, name, email, phone, address, mailbox) in result: tup = (borrower_id, 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. """ - (ccid, name, email, phone, address, mailbox) = user_info + (_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_hold_request(is_borrower, recid, barcode, period_from, period_to, status) db.update_item_status('requested', barcode) else: db.new_borrower(name, email, phone, address, mailbox, '') is_borrower = db.is_borrower(email) db.new_hold_request(is_borrower, recid, barcode, period_from, period_to, status) db.update_item_status('requested', barcode) 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, name, email, phone, address, mailbox) in result: tup = (borrower_id, 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, name, email, phone, address, mailbox) in result: tup = (borrower_id, 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, name, email, phone, address, mailbox) in result: tup = (borrower_id, 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(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, 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 = 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__) -def ordered_books(req, 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. """ infos = [] 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__) list_infos = [] if CFG_CERN_SITE == 1: from invenio.bibcirculation_cern_ldap import get_user_info_from_ldap if key =='name' and string: result = get_user_info_from_ldap(nickname=string) for i in range(len(result)): try: name = result[i][1]['cn'][0] except KeyError: name = "" try: ccid = result[i][1]['employeeID'][0] except KeyError: ccid = "" try: email = result[i][1]['mail'][0] except KeyError: email = "" try: phone = result[i][1]['telephoneNumber'][0] except KeyError: phone = "" try: address = result[i][1]['physicalDeliveryOfficeName'][0] except KeyError: address = "" try: mailbox = result[i][1]['postOfficeBox'][0] except KeyError: mailbox = "" tup = (ccid, name, email, phone, address, mailbox) list_infos.append(tup) elif key =='email' and string: result = get_user_info_from_ldap(email=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 =='ccid' and string: 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) 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, name, email, phone, address, mailbox) in result: tup = (borrower_id, name, email, phone, address, mailbox) list_infos.append(tup) body = bibcirculation_templates.tmpl_register_ill_request_step0(result=list_infos, 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') 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, ln=CFG_SITE_LANG): """ """ ill_req = db.get_ill_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_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, ill_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) ill_borrower_request = db.get_ill_borrower_request(ill_request_id) if ill_status == 'pending': ill_req_details = db.get_ill_request_pending(ill_request_id) elif ill_status == 'request sent, not yet received': ill_req_details = db.get_ill_request_sent(ill_request_id) elif ill_status == 'request cancelled': ill_req_details = db.get_ill_request_sent(ill_request_id) elif ill_status == 'item received, due date defined': ill_req_details = db.get_ill_request_received(ill_request_id) elif ill_status == 'item returned': ill_req_details = db.get_ill_request_returned(ill_request_id) else: ill_req_details = db.get_ill_request_returned(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_req_details=ill_req_details, libraries=libraries, ill_status=ill_status, ill_borrower_request=ill_borrower_request, ln=ln) return page(title="ILL request details", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def ill_request_details_step2(req, delete_key, ill_request_id, ill_status, library_id, request_date, expected_date, arrival_date, - due_date, return_date, status, cost, currency, barcode, library_notes, ln=CFG_SITE_LANG): + due_date, return_date, cost, currency, barcode, library_notes, ln=CFG_SITE_LANG): """ """ 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) ill_borrower_request = db.get_ill_borrower_request(ill_request_id) if ill_status == 'pending': request_info = (ill_request_id, library_notes) ill_req_details = db.get_ill_request_pending(ill_request_id) elif ill_status == 'request sent, not yet received': request_info = (ill_request_id, library_id, request_date, expected_date, cost, currency, barcode, library_notes) ill_req_details = db.get_ill_request_pending(ill_request_id) elif ill_status == 'request cancelled': request_info = (ill_request_id, cost, currency, barcode, library_notes) ill_req_details = db.get_ill_request_cancelled(ill_request_id) elif ill_status == 'item received, due date defined': request_info = (ill_request_id, arrival_date, due_date, cost, currency, barcode, library_notes) ill_req_details = db.get_ill_item_received(ill_request_id) elif ill_status == 'item returned': request_info = (ill_request_id, return_date, cost, currency, library_notes) ill_req_details = db.get_ill_item_returned(ill_request_id) else: request_info = (ill_request_id, library_notes) ill_req_details = db.get_ill_request_closed(ill_request_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_request_details_step2(ill_req_details=ill_req_details, request_info=request_info, ill_status=ill_status, ill_borrower_request=ill_borrower_request, ln=ln) return page(title="ILL request details", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def ill_request_details_step3(req, request_info, ill_status, ln=CFG_SITE_LANG): """ """ if ill_status == 'pending': (ill_request_id, library_notes) = request_info 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) db.update_ill_request_pending(ill_request_id, ill_status, str(library_previous_notes)) elif ill_status == 'request sent, not yet received': (ill_request_id, library_id, request_date, expected_date, cost, currency, barcode, library_notes) = request_info 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) db.update_ill_request_sent(ill_request_id, ill_status, library_id, request_date, expected_date, cost_format, barcode, str(library_previous_notes)) elif ill_status == 'request cancelled': (ill_request_id, cost, currency, barcode, library_notes) = request_info 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) db.update_ill_request_cancelled(ill_request_id, ill_status, cost_format, barcode, str(library_previous_notes)) elif ill_status == 'item received, due date defined': (ill_request_id, arrival_date, due_date, cost, currency, barcode, library_notes) = request_info 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) db.update_ill_item_received(ill_request_id, ill_status, arrival_date, due_date, cost_format, barcode, str(library_previous_notes)) 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 ill_status == 'item returned': (ill_request_id, return_date, cost, currency, library_notes) = request_info 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) db.update_ill_item_returned(ill_request_id, ill_status, return_date, cost_format, str(library_previous_notes)) 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') else: (ill_request_id, library_notes) = request_info 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) db.update_ill_request_closed(ill_request_id, ill_status, str(library_previous_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_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, 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) 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) 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, 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 = [] if key and not string: infos.append('Empty string. Please, try again.') book_info = (title, authors, place, publisher, year, edition, isbn) request_details = (period_of_interest_from, period_of_interest_to, additional_comments, only_edition) body = bibcirculation_templates.tmpl_register_ill_request_with_no_recid_step2(book_info=book_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: 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, name, email, phone, address, mailbox) in result: tup = (borrower_id, 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, name, email, phone, address, mailbox) in result: tup = (borrower_id, 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, name, email, phone, address, mailbox) in result: tup = (borrower_id, 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_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: book_info = (title, authors, place, publisher, year, edition, isbn) request_details = (period_of_interest_from, period_of_interest_to, additional_comments, only_edition) body = bibcirculation_templates.tmpl_register_ill_request_with_no_recid_step2(book_info=book_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 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): """ """ (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, name, email, phone, address, mailbox) = user_info + (borrower_id, _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, 'pending', str(ill_request_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_step3(ln=ln) return page(title="Register ILL request", uid=id_user, req=req, body=body, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) def get_borrower_ill_details(req, borrower_id, ill_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, ill_id=ill_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 """ 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(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, page, year, issn, + 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, page, year, issn) + volume, issue, pages, year, issn) request_details = (period_of_interest_from, period_of_interest_to, additional_comments) body = bibcirculation_templates.tmpl_register_ill_request_with_no_recid_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: 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, name, email, phone, address, mailbox) in result: tup = (borrower_id, 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, name, email, phone, address, mailbox) in result: tup = (borrower_id, 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, name, email, phone, address, mailbox) in result: tup = (borrower_id, 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, page, year, issn) + 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 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, navtrail=navtrail_previous_links, lastupdated=__lastupdated__) -def ill_search_result(req, p, f, ln=CFG_SITE_LANG): +def ill_search_result(p, f): """ 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 == '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) + + ### UNFINISHED ### + return result diff --git a/modules/bibcirculation/web/admin/bibcirculationadmin.py b/modules/bibcirculation/web/admin/bibcirculationadmin.py index 1c3d15b5e..d23fb8a0d 100644 --- a/modules/bibcirculation/web/admin/bibcirculationadmin.py +++ b/modules/bibcirculation/web/admin/bibcirculationadmin.py @@ -1,1061 +1,1061 @@ ## 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. """CDS Invenio BibCirculation Administrator (URLs) Interface.""" __revision__ = "" import invenio.bibcirculationadminlib as bal from invenio.config import CFG_SITE_LANG from invenio.urlutils import wash_url_argument from cgi import escape def index(req, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py """ return bal.index(req, ln) def borrower_search(req, empty_barcode=None, redirect='no', ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/borrowers_search """ return bal.borrower_search(req, empty_barcode, redirect=redirect, ln=ln) def item_search(req, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/holdings_search """ return bal.item_search(req, ln) def borrower_notification(req, borrower_id=None, template=None, message=None, load_msg_template=None, subject=None, send_message=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/borrower_notification """ return bal.borrower_notification(req, borrower_id, template, message, load_msg_template, subject, send_message, ln) def get_pending_requests(req, request_id=None, print_data=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/get_pending_requests """ return bal.get_pending_requests(req, request_id, print_data, ln) def item_search_result(req, p=None, f=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/item_search_result """ return bal.item_search_result(req, p, f, ln) def loan_return(req, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/loan_return """ return bal.loan_return(req, ln) def loan_on_desk_step1(req, key=None, string=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/loan_on_desk_step1 """ return bal.loan_on_desk_step1(req, key, string, ln) def loan_on_desk_step2(req, user_info=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/loan_on_desk_step2 """ user_info = user_info.split(',') return bal.loan_on_desk_step2(req, user_info, ln) def loan_on_desk_step3(req, user_info=None, barcode=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/loan_on_desk_step4 """ user_info = eval(user_info) return bal.loan_on_desk_step3(req, user_info, barcode, ln) def loan_on_desk_step4(req, list_of_books=None, user_info=None, due_date=None, note=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/loan_on_desk_step5 """ user_info = eval(user_info) list_of_books = eval(list_of_books) due_date = wash_url_argument(due_date, 'list') return bal.loan_on_desk_step4(req, list_of_books, user_info, due_date, note, ln) def loan_on_desk_confirm(req, barcode=None, borrower_id=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/loan_on_desk_confirm """ return bal.loan_on_desk_confirm(req, barcode, borrower_id, ln) def register_new_loan(req, barcode=None, borrower_id=None, request_id=None, new_note=None, print_data=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/register_new_loan """ return bal.register_new_loan(req, barcode, borrower_id, request_id, new_note, print_data, ln) def loan_return_confirm(req, barcode=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/loan_return_confirm """ return bal.loan_return_confirm(req, barcode, ln) def get_next_waiting_loan_request(req, recid=None, barcode=None, check_id=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/get_next_waiting_loan_request """ return bal.get_next_waiting_loan_request(req, recid, barcode, check_id, ln) def update_next_loan_request_status(req, check_id=None, barcode=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/update_next_loan_request_status """ return bal.update_next_loan_request_status(req, check_id, barcode, ln) def all_requests(req, request_id=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/all_requests """ return bal.all_requests(req, request_id, ln) def get_item_req_historical_overview(req, recid=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/get_item_req_historical_overview """ return bal.get_item_req_historical_overview(req, recid, ln) def get_item_loans_historical_overview(req, recid=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/get_item_loans_historical_overview """ return bal.get_item_loans_historical_overview(req, recid, ln) def all_loans_test(req, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/all_loans """ return bal.all_loans_test(req, ln) def all_loans(req, msg=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/all_loans """ return bal.all_loans(req, msg=msg, ln=ln) def bor_loans_historical_overview(req, borrower_id=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/bor_loans_historical_overview """ return bal.bor_loans_historical_overview(req, borrower_id, ln) def bor_requests_historical_overview(req, borrower_id=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/bor_requests_historical_overview """ return bal.bor_requests_historical_overview(req, borrower_id, ln) def get_item_requests_details(req, recid=None, request_id=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/borrowers_search """ return bal.get_item_requests_details(req, recid, request_id, ln) def get_item_loans_details(req, recid=None, barcode=None, loan_id=None, force=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/borrowers_search """ return bal.get_item_loans_details(req, recid, barcode, loan_id, force, ln) def get_borrower_details(req, borrower_id=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/borrowers_search """ return bal.get_borrower_details(req, borrower_id, ln) def get_item_details(req, recid=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/borrowers_search """ return bal.get_item_details(req, recid, ln) def get_library_details(req, library_id=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/get_library_details """ return bal.get_library_details(req, library_id, ln) def get_borrower_requests_details(req, borrower_id=None, request_id=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/get_borrower_requests_details """ return bal.get_borrower_requests_details(req, borrower_id, request_id, ln) def get_borrower_loans_details(req, recid=None, barcode=None, borrower_id=None, renewall=None, force=None, loan_id=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/get_borrower_loans_details """ return bal.get_borrower_loans_details(req, recid, barcode, borrower_id, renewall, force, loan_id, ln) def borrower_search_result(req, column, string, redirect='no', ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/borrower_search_result """ return bal.borrower_search_result(req, column, string, redirect=redirect, ln=ln) def associate_barcode(req, request_id=None, recid=None, borrower_id=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/associate_barcode """ return bal.associate_barcode(req, request_id, recid, borrower_id, ln) def get_borrower_notes(req, borrower_id=None, delete_key=None, library_notes=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/get_borrower_notes """ return bal.get_borrower_notes(req, borrower_id, delete_key, library_notes, ln) def get_loans_notes(req, loan_id=None, recid=None, delete_key=None, library_notes=None, back="", ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/get_loans_notes """ return bal.get_loans_notes(req, loan_id, recid, delete_key, library_notes, back, ln) -def get_item_loans_notes(req, loan_id=None, recid=None, borrower_id=None, +def get_item_loans_notes(req, loan_id=None, recid=None, add_notes=None, new_note=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/get_item_loans_notes """ - return bal.get_item_loans_notes(req, loan_id, recid, borrower_id, add_notes, + return bal.get_item_loans_notes(req, loan_id, recid, add_notes, new_note, ln) def new_item(req, isbn=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/new_item """ return bal.new_item(req, isbn, ln) def add_new_borrower_step1(req, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/add_new_borrower_step1 """ return bal.add_new_borrower_step1(req, ln) def add_new_borrower_step2(req, name=None, email=None, phone=None, address=None, mailbox=None, notes=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/add_new_borrower_step2 """ return bal.add_new_borrower_step2(req, name, email, phone, address, mailbox, notes, ln) def add_new_borrower_step3(req, tup_infos=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/add_new_borrower_step3 """ tup_infos = eval(tup_infos) return bal.add_new_borrower_step3(req, tup_infos, ln) def update_borrower_info_step1(req, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/update_borrower_info_step1 """ return bal.update_borrower_info_step1(req, ln) def update_borrower_info_step2(req, column=None, string=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/update_borrower_info_step2 """ return bal.update_borrower_info_step2(req, column, string, ln) def update_borrower_info_step3(req, borrower_id=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/update_borrower_info_step3 """ return bal.update_borrower_info_step3(req, borrower_id, ln) def update_borrower_info_step4(req, name=None, email=None, phone=None, address=None, mailbox=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/update_borrower_info_step4 """ return bal.update_borrower_info_step4(req, name, email, phone, address, mailbox, ln) def update_borrower_info_step5(req, tup_infos, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/update_borrower_info_step5 """ tup_infos = eval(tup_infos) return bal.update_borrower_info_step5(req, tup_infos, ln) def add_new_library_step1(req, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/add_new_library_step1 """ return bal.add_new_library_step1(req, ln) def add_new_library_step2(req, name=None, email=None, phone=None, address=None, type=None, notes=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/add_new_library_step2 """ return bal.add_new_library_step2(req, name, email, phone, address, type, notes, ln) def add_new_library_step3(req, tup_infos=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/add_new_library_step3 """ tup_infos = eval(tup_infos) return bal.add_new_library_step3(req, tup_infos, ln) def update_library_info_step1(req, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/update_library_info_step1 """ return bal.update_library_info_step1(req, ln) def update_library_info_step2(req, column=None, string=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/update_library_info_step2 """ return bal.update_library_info_step2(req, column, string, ln) def update_library_info_step3(req, library_id=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/update_library_info_step3 """ return bal.update_library_info_step3(req, library_id, ln) def update_library_info_step4(req, name=None, email=None, phone=None, address=None, library_id=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/update_library_info_step4 """ return bal.update_library_info_step4(req, name, email, phone, address, library_id, ln) def update_library_info_step5(req, tup_infos, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/update_library_info_step5 """ tup_infos = eval(tup_infos) return bal.update_library_info_step5(req, tup_infos, ln) def add_new_copy_step1(req, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/add_new_copy_step1 """ return bal.add_new_copy_step1(req, ln) def add_new_copy_step2(req, p=None, f=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/add_new_copy_step2 """ return bal.add_new_copy_step2(req, p, f, ln) def add_new_copy_step3(req, recid=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/add_new_copy_step3 """ return bal.add_new_copy_step3(req, recid, ln) def add_new_copy_step4(req, barcode=None, library=None, location=None, collection=None, description=None, loan_period=None, status=None, recid=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/add_new_copy_step4 """ return bal.add_new_copy_step4(req, barcode, library, location, collection, description, loan_period, status, recid, ln) def add_new_copy_step5(req, tup_infos=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/add_new_copy_step5 """ tup_infos = eval(tup_infos) return bal.add_new_copy_step5(req, tup_infos, ln) def update_item_info_step1(req, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/update_item_info_step1 """ return bal.update_item_info_step1(req, ln) def update_item_info_step2(req, p, f, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/update_item_info_step2 """ return bal.update_item_info_step2(req, p, f, ln) def update_item_info_step3(req, recid, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/update_item_info_step3 """ return bal.update_item_info_step3(req, recid, ln) def update_item_info_step4(req, barcode, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/update_item_info_step4 """ return bal.update_item_info_step4(req, barcode, ln) def update_item_info_step5(req, barcode, library, location, collection, description, loan_period, status, recid, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/update_item_info_step5 """ return bal.update_item_info_step5(req, barcode, library, location, collection, description, loan_period, status, recid, ln) def update_item_info_step6(req, tup_infos, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/update_item_info_step6 """ tup_infos = eval(tup_infos) return bal.update_item_info_step6(req, tup_infos, ln) def search_library_step1(req, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/search_library_step1 """ return bal.search_library_step1(req, ln) def search_library_step2(req, column, string, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/search_library_step2 """ return bal.search_library_step2(req, column, string, ln) def get_library_notes(req, library_id=None, delete_key=None, library_notes=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/get_library_notes """ return bal.get_library_notes(req, library_id, delete_key, library_notes, ln) def change_due_date_step1(req, loan_id=None, borrower_id=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/change_due_date_step1 """ return bal.change_due_date_step1(req, loan_id, borrower_id, ln) def change_due_date_step2(req, due_date=None, loan_id=None, borrower_id=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/change_due_date_step2 """ return bal.change_due_date_step2(req, due_date, loan_id, borrower_id, ln) def claim_book_return(req, borrower_id=None, recid=None, loan_id=None, template=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/claim_book_return """ return bal.claim_book_return(req, borrower_id, recid, loan_id, template, ln) def all_expired_loans(req, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/all_expired_loans """ return bal.all_expired_loans(req, ln) def get_waiting_requests(req, request_id=None, print_data=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/get_waiting_requests """ return bal.get_waiting_requests(req, request_id, print_data, ln) def create_new_loan_step1(req, borrower_id=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/create_new_loan_step1 """ return bal.create_new_loan_step1(req, borrower_id, ln) def create_new_loan_step2(req, borrower_id=None, barcode=None, notes=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/create_new_loan_step2 """ return bal.create_new_loan_step2(req, borrower_id, barcode, notes, ln) def create_new_request_step1(req, borrower_id=None, p=None, f=None, search=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/create_new_request_step1 """ return bal.create_new_request_step1(req, borrower_id, p, f, search, ln) def create_new_request_step2(req, recid=None, borrower_id=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/create_new_request_step2 """ return bal.create_new_request_step2(req, recid, borrower_id, ln) def create_new_request_step3(req, borrower_id=None, barcode=None, recid=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/create_new_request_step3 """ return bal.create_new_request_step3(req, borrower_id, barcode, recid, ln) def create_new_request_step4(req, period_from=None, period_to=None, barcode=None, borrower_id=None, recid=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/create_new_request_step4 """ return bal.create_new_request_step4(req, period_from, period_to, barcode, borrower_id, recid, ln) def place_new_request_step1(req, barcode=None, recid=None, key=None, string=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/place_new_request_step1 """ return bal.place_new_request_step1(req, barcode, recid, key, string, ln) def place_new_request_step2(req, barcode=None, recid=None, user_info=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/place_new_request_step2 """ if user_info is not None: user_info = user_info.split(',') return bal.place_new_request_step2(req, barcode, recid, user_info, ln) def place_new_request_step3(req, barcode=None, recid=None, user_info=None, period_from=None, period_to=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/place_new_request_step3 """ user_info = eval(user_info) return bal.place_new_request_step3(req, barcode, recid, user_info, period_from, period_to, ln) def place_new_loan_step1(req, barcode=None, recid=None, key=None, string=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/place_new_loan_step1 """ return bal.place_new_loan_step1(req, barcode, recid, key, string, ln) def place_new_loan_step2(req, barcode=None, recid=None, user_info=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/place_new_loan_step2 """ return bal.place_new_loan_step2(req, barcode, recid, user_info, ln) def place_new_loan_step3(req, barcode=None, recid=None, ccid=None, name=None, email=None, phone=None, address=None, mailbox=None, due_date=None, notes=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/place_new_loan_step3 """ return bal.place_new_loan_step3(req, barcode, recid, ccid, name, email, phone, address, mailbox, due_date, notes, ln) def order_new_copy_step1(req, recid=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/order_new_copy_step1 """ return bal.order_new_copy_step1(req, recid, ln) def order_new_copy_step2 (req, recid=None, barcode=None, vendor_id=None, cost=None, currency=None, status=None, order_date=None, expected_date=None, library_id=None, notes=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/order_new_copy_step2 """ return bal.order_new_copy_step2(req, recid, barcode, vendor_id, cost, currency, status, order_date, expected_date, library_id, notes, ln) def order_new_copy_step3(req, order_info=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/order_new_copy_step3 """ order_info = eval(order_info) return bal.order_new_copy_step3(req, order_info, ln) def ordered_books(req, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/ordered_books """ - return bal.ordered_books(req, ln) + return bal.list_ordered_books(req, ln) def get_purchase_notes(req, purchase_id=None, delete_key=None, library_notes=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/get_purchase_notes """ return bal.get_purchase_notes(req, purchase_id, delete_key, library_notes, ln) def register_ill_request_step0(req, recid=None, key=None, string=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/register_ill_request_step0 """ return bal.register_ill_request_step0(req, recid, key, string, ln) def register_ill_request_step1(req, recid=None, user_info=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/register_ill_request_step1 """ return bal.register_ill_request_step1(req, recid, user_info, ln) def register_ill_request_step2(req, recid=None, user_info=None, period_of_interest_from=None, period_of_interest_to=None, notes=None, only_edition=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/register_ill_request_step2 """ return bal.register_ill_request_step2(req, recid, user_info, period_of_interest_from, period_of_interest_to, notes, only_edition, ln) def register_ill_request_step3(req, borrower_id=None, request_info=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/register_ill_request_step3 """ request_info = eval(request_info) return bal.register_ill_request_step3(req, borrower_id, request_info, ln) def list_ill_request(req, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/list_ill_request """ return bal.list_ill_request(req, ln) def ill_request_details_step1(req, delete_key=None, ill_request_id=None, ill_status=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/ill_request_details_step1 """ return bal.ill_request_details_step1(req, delete_key, ill_request_id, ill_status, ln) def ill_request_details_step2(req, delete_key=None, ill_request_id=None, ill_status=None, library_id=None, request_date=None, expected_date=None, arrival_date=None, due_date=None, return_date=None, status=None, cost=None, currency=None, barcode=None, library_notes=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/ill_request_details_step2 """ - return bal.ill_request_details_step2(req, delete_key, ill_request_id, ill_status, library_id, + return bal.ill_request_details_step2(req, delete_key, ill_request_id, library_id, request_date, expected_date, arrival_date, due_date, return_date, status, cost, currency, barcode, library_notes, ln) def ill_request_details_step3(req, request_info=None, ill_status=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/ill_request_details_step3 """ request_info = eval(request_info) return bal.ill_request_details_step3(req, request_info, ill_status, ln) def ordered_books_details_step1(req, purchase_id=None, delete_key=None, ln=CFG_SITE_LANG): """ """ return bal.ordered_books_details_step1(req, purchase_id, delete_key, ln) def ordered_books_details_step2(req, purchase_id=None, recid=None, vendor_id=None, cost=None, currency=None, status=None, order_date=None, expected_date=None, purchase_notes=None, library_notes=None, ln=CFG_SITE_LANG): """ """ return bal.ordered_books_details_step2(req, purchase_id, recid, vendor_id, cost, currency, status, order_date, expected_date, purchase_notes, library_notes, ln) def ordered_books_details_step3(req, purchase_id=None, recid=None, vendor_id=None, cost=None, currency=None, status=None, order_date=None, expected_date=None, purchase_notes=None, library_notes=None, ln=CFG_SITE_LANG): """ """ return bal.ordered_books_details_step3(req, purchase_id, recid, vendor_id, cost, currency, status, order_date, expected_date, purchase_notes, library_notes, ln) def add_new_vendor_step1(req, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/add_new_vendor_step1 """ return bal.add_new_vendor_step1(req, ln) def add_new_vendor_step2(req, name=None, email=None, phone=None, address=None, notes=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/add_new_vendor_step2 """ return bal.add_new_vendor_step2(req, name, email, phone, address, notes, ln) def add_new_vendor_step3(req, tup_infos=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/add_new_vendor_step3 """ tup_infos = eval(tup_infos) return bal.add_new_vendor_step3(req, tup_infos, ln) def update_vendor_info_step1(req, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/update_vendor_info_step1 """ return bal.update_vendor_info_step1(req, ln) def update_vendor_info_step2(req, column=None, string=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/update_vendor_info_step2 """ return bal.update_vendor_info_step2(req, column, string, ln) def update_vendor_info_step3(req, vendor_id=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/update_vendor_info_step3 """ return bal.update_vendor_info_step3(req, vendor_id, ln) def update_vendor_info_step4(req, name=None, email=None, phone=None, address=None, vendor_id=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/update_vendor_info_step4 """ return bal.update_vendor_info_step4(req, name, email, phone, address, vendor_id, ln) def update_vendor_info_step5(req, tup_infos, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/update_vendor_info_step5 """ tup_infos = eval(tup_infos) return bal.update_vendor_info_step5(req, tup_infos, ln) def search_vendor_step1(req, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/search_vendor_step1 """ return bal.search_vendor_step1(req, ln) def search_vendor_step2(req, column, string, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/search_vendor_step2 """ return bal.search_vendor_step2(req, column, string, ln) def get_vendor_details(req, vendor_id=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/get_vendor_details """ return bal.get_vendor_details(req, vendor_id, ln) def get_vendor_notes(req, vendor_id=None, add_notes=None, new_note=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/get_vendor_notes """ return bal.get_vendor_notes(req, vendor_id, add_notes, new_note, ln) def register_ill_request_with_no_recid_step1(req, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/register_ill_request_with_no_recid_step1 """ return bal.register_ill_request_with_no_recid_step1(req, ln) def register_ill_request_with_no_recid_step2(req, title=None, authors=None, place=None, publisher=None, year=None, edition=None, isbn=None, period_of_interest_from=None, period_of_interest_to=None, additional_comments=None, only_edition=None, key=None, string=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/register_ill_request_with_no_recid_step2 """ return bal.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) def register_ill_request_with_no_recid_step3(req, book_info=None, user_info=None, request_details=None, ln=CFG_SITE_LANG): """ """ if type(book_info) is str: book_info = eval(book_info) if type(request_details) is str: request_details = eval(request_details) if type(user_info) is str: user_info = user_info.split(',') return bal.register_ill_request_with_no_recid_step3(req, book_info, user_info, request_details, ln) def register_ill_request_with_no_recid_step4(req, book_info=None, user_info=None, request_details=None, ln=CFG_SITE_LANG): """ """ #################################### f=open("/tmp/book_info","w") ### f.write(str(book_info)+"\n") ### f.close() ### #################################### if type(book_info) is str: book_info = eval(book_info) if type(request_details) is str: request_details = eval(request_details) if type(user_info) is str: user_info = eval(user_info) return bal.register_ill_request_with_no_recid_step4(req, book_info, user_info, request_details, ln) def get_borrower_ill_details(req, borrower_id=None, ill_id=None, ln=CFG_SITE_LANG): """ """ return bal.get_borrower_ill_details(req, borrower_id, ill_id, ln) def get_ill_library_notes(req, ill_id=None, delete_key=None, library_notes=None, ln=CFG_SITE_LANG): """ """ return bal.get_ill_library_notes(req, ill_id, delete_key, library_notes, ln) def get_expired_loans_with_requests(req, request_id=None, ln=CFG_SITE_LANG): """ """ return bal.get_expired_loans_with_requests(req, request_id, ln) def register_ill_book_request(req, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/holdings_search """ return bal.register_ill_book_request(req, ln) def register_ill_book_request_result(req, p=None, f=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/item_search_result """ return bal.register_ill_book_request_result(req, p, f, ln) def register_ill_book_request_from_borrower_page(req, borrower_id=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/holdings_search """ return bal.register_ill_book_request_from_borrower_page(req, borrower_id, ln) def register_ill_book_request_from_borrower_page_result(req, borrower_id=None, p=None, f=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/item_search_result """ return bal.register_ill_book_request_from_borrower_page_result(req, borrower_id, p, f, ln) def register_ill_request_from_borrower_page_step1(req, borrower_id=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/register_ill_request_with_no_recid_step1 """ return bal.register_ill_request_from_borrower_page_step1(req, borrower_id, ln) def register_ill_request_from_borrower_page_step2(req, borrower_id=None, title=None, authors=None, place=None, publisher=None, year=None, edition=None, isbn=None, period_of_interest_from=None, period_of_interest_to=None, additional_comments=None, only_edition=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/register_ill_request_with_no_recid_step2 """ return bal.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) def register_ill_article_request_step1(req, ln=CFG_SITE_LANG): """ """ return bal.register_ill_article_request_step1(req, ln) def register_ill_article_request_step2(req, periodical_title=None, article_title=None, author=None, report_number=None, volume=None, issue=None, page=None, year=None, issn=None, period_of_interest_from=None, period_of_interest_to=None, additional_comments=None, key=None, string=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/register_ill_request_with_no_recid_step2 """ return bal.register_ill_article_request_step2(req, periodical_title, article_title, author, report_number, volume, issue, page, year, issn, period_of_interest_from, period_of_interest_to, additional_comments, key, string, ln) def ill_search(req, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/holdings_search """ return bal.ill_search(req, ln) def ill_search_result(req, p=None, f=None, ln=CFG_SITE_LANG): """ http://cdsweb.cern.ch/admin/bibcirculation/bibcirculationadmin.py/item_search_result """ - return bal.ill_search_result(req, p, f, ln) + return bal.ill_search_result(p, f)