Example #1
0
def update():
    if request.method == "GET":
        todo_id = request.args.get("id", "")
        return render_template("todo_edit.html", todo_id=todo_id)
    form = request.form
    todo_id = form.get("id", "")
    todo = Todo.find_by_id(todo_id)
    # update todo in the db
    _updateTodo(todo, form)
    Todo.delete(todo_id)
    todo.save()
    # get all the todos to render template
    todos = Todo.all()
    return render_template("todo.html", todos=todos)
Example #2
0
def delete():
    todo_id = request.args.get("id", "")
    Todo.delete(todo_id)
    todos = Todo.all()
    return render_template("todo.html", todos=todos)