def setup(): from openlibrary.core import msgbroker msgbroker.subscribe("loan-created", on_loan_created) msgbroker.subscribe("loan-completed", on_loan_completed) msgbroker.subscribe("loan-created", on_loan_created_statsdb) msgbroker.subscribe("loan-completed", on_loan_completed_statsdb)
def make_bookreader_auth_link(loan_key, item_id, book_path, ol_host): """ Generate a link to BookReaderAuth.php that starts the BookReader with the information to initiate reading a borrowed book """ olAuthUrl = "https://{0}/ia_auth/XXX".format(ol_host) access_token = make_ia_token(item_id, bookreader_auth_seconds) auth_url = 'https://%s/bookreader/BookReaderAuth.php?uuid=%s&token=%s&id=%s&bookPath=%s&olHost=%s&olAuthUrl=%s' % ( bookreader_host, loan_key, access_token, item_id, book_path, ol_host, olAuthUrl) return auth_url def on_loan_update(loan): # update the waiting list and ebook document. waitinglist.update_waitinglist(loan['ocaid']) def on_loan_delete(loan): # update the waiting list and ebook document. waitinglist.update_waitinglist(loan['ocaid']) msgbroker.subscribe("loan-created", on_loan_update) msgbroker.subscribe("loan-completed", on_loan_delete) lending.setup(config)
if token_hmac == expected_hmac: return True return False def make_bookreader_auth_link(loan_key, item_id, book_path, ol_host): """ Generate a link to BookReaderAuth.php that starts the BookReader with the information to initiate reading a borrowed book """ olAuthUrl = "https://{0}/ia_auth/XXX".format(ol_host) access_token = make_ia_token(item_id, bookreader_auth_seconds) auth_url = 'https://%s/bookreader/BookReaderAuth.php?uuid=%s&token=%s&id=%s&bookPath=%s&olHost=%s&olAuthUrl=%s' % ( bookreader_host, loan_key, access_token, item_id, book_path, ol_host, olAuthUrl ) return auth_url def on_loan_update(loan): # update the waiting list and ebook document. waitinglist.update_waitinglist(loan['ocaid']) def on_loan_delete(loan): # update the waiting list and ebook document. waitinglist.update_waitinglist(loan['ocaid']) msgbroker.subscribe("loan-created", on_loan_update) msgbroker.subscribe("loan-completed", on_loan_delete) lending.setup(config)
def setup(): """Installs handlers for various events. """ msgbroker.subscribe("page.edit.libraries", on_library_edit) msgbroker.subscribe("page.edit", on_page_edit)