def POST(self): payload = web.data() d = simplejson.loads(payload) identifier = d and d.get('identifier') if identifier: lending.sync_loan(identifier) waitinglist.on_waitinglist_update(identifier)
def GET(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 edition.ocaid: lending.sync_loan(edition.ocaid) ebook_key = "ebooks/" + edition.ocaid ebook = web.ctx.site.store.get(ebook_key) or {} else: ebook = None edition_loans = get_edition_loans(edition) user_loans = [] user = accounts.get_current_user() if user: user_loans = get_loans(user) return render_template("borrow_admin", edition, edition_loans, ebook, user_loans, web.ctx.ip)
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() raise web.seeother(web.ctx.path + '/borrow_admin')
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')
def update_loan_status(self): """Update the status of this user's loans.""" loans = lending.get_loans_of_user(self.key) for loan in loans: lending.sync_loan(loan['ocaid'])
def update_loan_status(self): """Update the loan status""" if self.ocaid: lending.sync_loan(self.ocaid)