示例#1
0
文件: views.py 项目: Windfarer/todo
def close_subtask(task_id,subtask_id):
    form=SubTaskForm(request.form)    
    task=Task.objects(id=ObjectId(task_id)).first()
    task.subtasks[subtask_id].status=True
    task.subtasks[subtask_id].endtime=datetime.now().date()
    task.save()
    return redirect('/task/pending')
    
示例#2
0
文件: views.py 项目: Windfarer/todo
def edit_subtask(task_id,subtask_id):
    form=SubTaskForm(request.form)
    task=Task.objects(id=ObjectId(task_id)).first()
    subtask=task.subtasks[subtask_id]
    if request.method == 'POST' and form.validate():
        form=SubTaskForm(request.form)    
        task.subtasks[subtask_id].content=form.content.data
        task.subtasks[subtask_id].deadline=form.deadline.data
        task.save()
        return redirect('/task/pending')
    return render_template('edit_sub.html', form=form, subtask=subtask,task_id=task_id,subtask_id=subtask_id)
示例#3
0
文件: views.py 项目: Windfarer/todo
def add_subtask(task_id):
    nowdate=datetime.now()
    form=SubTaskForm(request.form)    
    task=Task.objects(id=ObjectId(task_id)).first()
    if request.method == 'POST' and form.validate():
        subtask = SubTask()
        form.populate_obj(subtask)
        subtask.id = ObjectId()
        task.subtasks.append(subtask)        
        task.save()
        return redirect('/task/pending')
    return render_template('add_sub.html', form=form , task_id=task_id, nowdate=nowdate)
示例#4
0
文件: views.py 项目: Windfarer/todo
def edit_task(task_id):
    form=TaskForm(request.form)
    task=Task.objects(id=ObjectId(task_id)).first()
    namelist=[]
    for i in task.assignlist:
        namelist.append(i.user)
    namelist=" ".join(namelist)
    if request.method == 'POST' and form.validate():
        task.content=form.content.data
        task.deadline=form.deadline.data
        task.assignlist=[]
        recipients=[]
        if not form.assign.data:
           task.assignlist.append(AssignList(user=g.user.username))
        else:
           for user in form.assign.data.split():
               if User.objects(username=user):
                   assign = AssignList(user=user)
                   task.assignlist.append(assign)
        task.save()
        
        return redirect('/task/pending')
    return render_template('edit.html', form=form, task=task,task_id=task_id,namelist=namelist)
示例#5
0
文件: views.py 项目: Windfarer/todo
def show_finished():
    tasks=Task.objects(status=True)
    for task in tasks:
        task.subtasks=enumerate(task.subtasks)
    return render_template('show_finished.html',tasks=tasks,title='Finished Tasks')
示例#6
0
文件: views.py 项目: Windfarer/todo
def show_pending():
    tasks=Task.objects(status=False)
    for task in tasks:
        task.subtasks=enumerate(task.subtasks)
    return render_template('show_pending.html',tasks=tasks,title='Pending Tasks')
示例#7
0
文件: views.py 项目: Windfarer/todo
def delete_subtask(task_id,subtask_id):
    form=SubTaskForm(request.form)    
    task=Task.objects(id=ObjectId(task_id)).first()
    del task.subtasks[subtask_id]
    task.save()
    return redirect('/task/pending')
示例#8
0
文件: views.py 项目: Windfarer/todo
def close_task(task_id):
    task=Task.objects(id=ObjectId(task_id)).first()
    task.endtime=datetime.now()
    task.status=True
    task.save()
    return redirect('/task/pending')
示例#9
0
文件: views.py 项目: Windfarer/todo
def delete_task(task_id):
    Task.objects(id=ObjectId(task_id)).first().delete()
    return redirect('/task/pending')
示例#10
0
文件: views.py 项目: Windfarer/todo
def show_timeout():
    tasks=Task.objects(deadline__lte=datetime.now(),status=False)
    for task in tasks:
        task.subtasks=enumerate(task.subtasks)
    return render_template('show_timeout.html',tasks=tasks,title='Timeout Tasks',timeout=True)