示例#1
0
def add():
    form = TodoForm(request.form)
    if form.validate():
        content = form.content.data
        todo = Todo(content=content, time=datetime.now())
        todo.save()
    return redirect(url_for('index'))
示例#2
0
def add():
    form = TodoForm(request.form)
    if form.validate():
        content = form.content.data
        todo = Todo(content=content,time=datetime.now())
        todo.save()
    todos = Todo.objects.order_by('-time')
    return render_template("index.html",todos=todos,form=form)
示例#3
0
def add():
    form = TodoForm(request.form)
    if form.validate():
        content = form.content.data
        todo = Todo(content=content)
        todo.save()
    todos = Todo.objects.order_by('-time')
    return render_template("index.html", todos=todos, form=form)
示例#4
0
def add():
    form = TodoForm(request.form)
    if form.validate():
        content = form.content.data
        todo = Todo(content=content)
        todo.save()
    todos = Todo.objects.all()
    return render_template("index.html", todos=todos, form=form)
示例#5
0
def add():
    form = TodoForm(request.form)
    if form.validate():
        content = form.content.data
        todo = Todo(content = content)
        todo.save()
    # Show all the list again
    todos = Todo.objects.order_by('-time')
    return render_template("index.html", todos = todos, form = form)
示例#6
0
文件: views.py 项目: cytues/Todo
def add():
    # request传入表单数据
    form = TodoForm(request.form)
    # 表单验证
    if form.validate():
        # 将表单内容传入
        content = form.content.data
        todo = Todo(content = content, time = datetime.now())
        # 保存todo表单
        todo.save()
    todos = Todo.objects.order_by('-time')
    return render_template('index.html', todos=todos, form=form)
示例#7
0
文件: views.py 项目: ttop5/Todo
def add():
    # print(request.form)
    form = TodoForm(request.form)
    # print form.__dict__
    if form.validate():
        content = form.content.data
        todo = Todo(content=content, time=datetime.now())
        # todo = Todo()
        # todo.content = content
        todo.save()
    todos = Todo.objects.order_by("-time")
    return render_template("index.html", todos=todos, form=form)
示例#8
0
def undone(todo_id):
    form = TodoForm()
    todo = Todo.objects.get_or_404(id=todo_id)
    todo.status = 0
    todo.save()
    todos = Todo.objects.order_by('-time')
    return render_template("index.html", todos=todos, form=form)
示例#9
0
def index():
    form = TodoForm()
    todos = Todo.objects.order_by('-time')
    return render_template("index.html",
                           todos=todos,
                           form=form,
                           version=app_version())
示例#10
0
def delete(todo_id):
    form = TodoForm()
    todo = Todo.objects.get_or_404(id=todo_id)
    todo.delete()
    todos = Todo.objects.order_by('-time')
    return render_template("index.html",
                           todos=todos,
                           form=form,
                           version=app_version())
示例#11
0
def done(todo_id):
    form = TodoForm()
    todo = Todo.objects.get_or_404(id=todo_id)
    todo.status = 1
    todo.save()
    todos = Todo.objects.order_by('-time')
    return render_template("index.html",
                           todos=todos,
                           form=form,
                           version=app_version(),
                           hostname=hostname())
示例#12
0
def index():
    form = TodoForm()
    todos = Todo.objects.order_by('+time')
    return render_template("index.html", todos=todos, form=form)
示例#13
0
文件: views.py 项目: hawk2020/todo
def delete(todo_id):
    form = TodoForm()
    todo = Todo.objects.get_or_404(id=todo_id)
    todo.delete()
    todos = Todo.objects.order_by('-time')
    return render_template('index.html',todos=todos,form=form)