示例#1
0
def main():
    try:
        cmd = sys.argv[1]
    except IndexError:
        cmd = "help"

    if cmd == "update-loans":
        borrow.update_all_loan_status()
    elif cmd == "update-waitinglist":
        waitinglist.update_waitinglist(sys.argv[2])
    else:
        usage()
示例#2
0
def main():
    try:
        cmd = sys.argv[1]
    except IndexError:
        cmd = "help"

    if cmd == "update-loans":
        borrow.update_all_loan_status()
    elif cmd == "update-waitinglist":
        waitinglist.update_waitinglist(sys.argv[2])
    else:
        usage()
示例#3
0
文件: borrow.py 项目: dbs/openlibrary
    def POST(self, key):
        if not is_admin():
            return render_template('permission_denied', web.ctx.path, "Permission denied.")

        edition = web.ctx.site.get(key)
        if not edition:
            raise web.notfound()
            
        i = web.input(action=None, loan_key=None)

        if i.action == 'delete' and i.loan_key:
            delete_loan(i.loan_key)
        elif i.action == 'update_loan_info':
            waitinglist.update_waitinglist(key)

        raise web.seeother(web.ctx.path + '/borrow_admin')
示例#4
0
文件: borrow.py 项目: dbs/openlibrary
def on_loan_update(loan):
    store = web.ctx.site.store

    # key = "ebooks" + loan['book']
    # doc = store.get(key) or {}
    # doc.update({
    #     "type": "ebook",
    #     "book_key": loan['book'],
    #     "borrowed": "true"
    # })
    # store[key] = doc

    # update the waiting list and ebook document.
    waitinglist.update_waitinglist(loan['book'])

    # TODO: differentiate between loan-updated and loan-created
    msgbroker.send_message("loan-created", loan)
示例#5
0
    def POST(self, key):
        if not is_admin():
            return render_template('permission_denied', web.ctx.path,
                                   "Permission denied.")

        edition = web.ctx.site.get(key)
        if not edition:
            raise web.notfound()

        i = web.input(action=None, loan_key=None)

        if i.action == 'delete' and i.loan_key:
            delete_loan(i.loan_key)
        elif i.action == 'update_loan_info':
            waitinglist.update_waitinglist(key)

        raise web.seeother(web.ctx.path + '/borrow_admin')
示例#6
0
def on_loan_update(loan):
    store = web.ctx.site.store

    # key = "ebooks" + loan['book']
    # doc = store.get(key) or {}
    # doc.update({
    #     "type": "ebook",
    #     "book_key": loan['book'],
    #     "borrowed": "true"
    # })
    # store[key] = doc

    # update the waiting list and ebook document.
    waitinglist.update_waitinglist(loan['book'])

    # TODO: differentiate between loan-updated and loan-created
    msgbroker.send_message("loan-created", loan)
示例#7
0
    def POST(self, key):
        if not is_admin():
            return render_template('permission_denied', web.ctx.path, "Permission denied.")

        edition = web.ctx.site.get(key)
        if not edition:
            raise web.notfound()
        if not edition.ocaid:
            raise web.seeother(edition.url("/borrow_admin"))

        lending.sync_loan(edition.ocaid)
        i = web.input(action=None, loan_key=None)

        if i.action == 'delete' and i.loan_key:
            loan = lending.get_loan(edition.ocaid)
            if loan and loan['_key'] == i.loan_key:
                loan.delete()
        elif i.action == 'update_loan_info':
            waitinglist.update_waitinglist(edition.ocaid)
        raise web.seeother(web.ctx.path + '/borrow_admin')
示例#8
0
文件: borrow.py 项目: dbs/openlibrary
def on_loan_delete(loan):
    store = web.ctx.site.store
    loan['returned_at'] = time.time()

    # Check if the book still has an active loan
    
    # borrowed = "false"
    # loan_keys = store.query('/type/loan', 'resource_id', loan['resource_id'])
    # if loan_keys:
    #     borrowed = "true"

    # key = "ebooks" + loan['book']
    # doc = store.get(key) or {}
    # doc.update({
    #     "type": "ebook",
    #     "book_key": loan['book'],
    #     "borrowed": borrowed
    # })
    # store[key] = doc

    # update the waiting list and ebook document.
    waitinglist.update_waitinglist(loan['book'])

    msgbroker.send_message("loan-completed", loan)
示例#9
0
def on_loan_delete(loan):
    store = web.ctx.site.store
    loan['returned_at'] = time.time()

    # Check if the book still has an active loan

    # borrowed = "false"
    # loan_keys = store.query('/type/loan', 'resource_id', loan['resource_id'])
    # if loan_keys:
    #     borrowed = "true"

    # key = "ebooks" + loan['book']
    # doc = store.get(key) or {}
    # doc.update({
    #     "type": "ebook",
    #     "book_key": loan['book'],
    #     "borrowed": borrowed
    # })
    # store[key] = doc

    # update the waiting list and ebook document.
    waitinglist.update_waitinglist(loan['book'])

    msgbroker.send_message("loan-completed", loan)
示例#10
0
def on_loan_delete(loan):
    # update the waiting list and ebook document.
    waitinglist.update_waitinglist(loan['ocaid'])
示例#11
0
def on_loan_delete(loan):
    # update the waiting list and ebook document.
    waitinglist.update_waitinglist(loan['ocaid'])