def GET(self, id): bids = model.getBids(int(id)) D = model.get_by_id(int(id)) if D is not None: return render.viewItem(D, id, bids, self.bid) if bids is None: return render.viewItem(D, id, bids, self.bid)
def POST(self, id): todo = model.get_by_id(id) if not todo: raise web.seeother('/?err=none') data = web.input() if not data.get('title'): return render_without_layout.warning('需要输入内容', '/edit/%s' % id) model.update_title(id, data.title) return render_without_layout.warning('修改成功', '/')
def get_by_id(cls, task_id: str): db_task = model.get_by_id(task_id) if not db_task: raise InvalidTaskError( 'task with id {} was not found'.format(task_id)) result = {'status': db_task.status} if db_task.status == model.Task.SUCCESS: result['id'] = db_task.id result['url'] = db_task.url result['md5'] = db_task.md5 elif db_task.status == model.Task.ERROR: raise TaskFailedError() return result
def POST(self, id): bids = model.getBids(int(id)) D = model.get_by_id(int(id)) if D.open == 0: raise web.seeother('/') highestBid = model.highestBid(int(id)) buy_price = D.price if highestBid is not None: self.bid.validators.append( form.Validator( "Bid is too low insert higher bid (" + str(highestBid.price) + " by " + highestBid.buyer + ")", lambda i: float(i.price) > highestBid.price)) self.bid.validators.append( form.Validator( "Bid is too high insert lower bid (" + str(buy_price) + ")", lambda i: float(i.price) <= buy_price)) if not self.bid.validates(): return render.viewItem(D, id, bids, self.bid) else: model.newBid(id, self.bid.d.buyer, self.bid.d.price) raise web.seeother('/viewItem/' + str(id))
def GET(self, id): todo = model.get_by_id(id) if not todo: raise web.seeother('/?err=none') return render.edit(todo)
def GET(self, id): title = model.get_by_id(id) if title: model.del_by_id(id) raise web.seeother('/') raise web.seeother('/?err=none')