Beispiel #1
0
def update(ToDo_id):
    form = TodoForm()
    ToDo_to_update = ToDoList.query.get(ToDo_id)
    if form.validate_on_submit():
        ToDo_to_update.name = form.task.data
        db.session.commit()
        return redirect(url_for('index'))
    return render_template('update.html', form=form)
Beispiel #2
0
def add():
    form = TodoForm()
    if form.validate_on_submit():
        todo = Todos(task=form.task.data, complete=False)
        db.session.add(todo)
        db.session.commit()
        return redirect(url_for('index'))
    return render_template('add.html', title="Add a new todo", form=form)
Beispiel #3
0
def add():
    form = TodoForm()
    if form.validate_on_submit():
        new_todo = ToDoList(name=form.task.data)
        db.session.add(new_todo)
        db.session.commit()
        return redirect(url_for('index'))
    return render_template('add.html', form=form)
def add():
    form = TodoForm()
    if form.validate_on_submit():
        new_todo = Todo(todo=form.todo.data)
        db.session.add(new_todo)
        db.session.commit()
        return redirect(url_for('index'))
    return render_template('add.html', title="Add a new todo", form=form)
Beispiel #5
0
def update(id):
    form = TodoForm()
    todo = Todos.query.get(id)
    if form.validate_on_submit():
        todo.task = form.task.data
        db.session.commit()
        redirect(url_for('index'))
    elif request.method == 'GET':
        form.task.data = todo.task
    return render_template('update.html', title='Update your todo', form=form)
Beispiel #6
0
def update(todo_id):
    form = TodoForm()
    todo_to_update = Todos.query.get(todo_id)
    if form.validate_on_submit():
        todo_to_update.task = form.task.data
        db.session.commit()
        return redirect(url_for('index'))
    elif request.method == "GET":
        form.task.data = todo_to_update.task
    return render_template('update.html', form=form)
Beispiel #7
0
def add():
    error = ""
    form = TodoForm()

    if request.method == 'POST':
        if form.validate_on_submit():
            name = form.name.data
            todo = Todos(name=name)
            db.session.add(todo)
            db.session.commit()
            return redirect(url_for('index'))
    return render_template('add.html', form=form)
Beispiel #8
0
def update(id):
    form = TodoForm()
    current = Todos.query.get(id)
    if request.method == 'GET':
        form.name.data = current.name
    if request.method == 'POST':
        current.name = form.name.data
        db.session.commit()
        return redirect(url_for('index'))

    return render_template('add.html', form=form)