def delete(request): todo_id = int(request.query.get('id')) t = Todo.find_by(id=todo_id) check_id(request, id=todo_id) Todo.remove(todo_id) # 不管如何,都需要返回json的数据,为了触发ajax中回调函数 return json_response(t.json())
def switch(request): todo_id = int(request.query.get('id')) check_id(request, id=todo_id) status = request.query.get('status') t = Todo.complete(todo_id, status) return json_response(t.json())
def update(request): form = request.json() check_id(request, form) newTodo = Todo.update(form) return json_response(newTodo.json())
def switch(request): todo_id = int(request.query.get('id')) check_id(request, id=todo_id) status = request.query.get('completed') t = Todo.complete(todo_id, status) return redirect('/todo/index')
def delete(request): todo_id = int(request.query.get('id')) check_id(request, id=todo_id) Todo.remove(todo_id) return redirect('/todo/index')
def update(request): form = request.form() check_id(request, form) newTodo = Todo.update(form) return redirect('/todo/index')