Exemplo n.º 1
0
def delete_task(project_key, task_key):
    project = Project.get_project(project_key)
    if project is None:
        abort(404)
    task = Task.get_task(project, task_key)
    flash('Task deleted: ' + task.title)
    task.delete()
    return redirect(url_for('view_project', project_key=project_key))
Exemplo n.º 2
0
def delete_comment(project_key, task_key):
    project = Project.get_project(project_key)
    if project is None:
        abort(404)
    task = Task.get_task(project, task_key)
    deletion_id = int(request.form['delete_comment'])
    task.delete_comment(deletion_id)
    flash('Comment was deleted')
    return redirect(
        url_for('view_task', project_key=project_key, task_key=task_key))
Exemplo n.º 3
0
def toggle_task_status(project_key, task_key):
    project = Project.get_project(project_key)
    if project is None:
        abort(404)
    task = Task.get_task(project, task_key)
    if task.status == 0:
        flash('Completed: ' + task.title)
        task.set_status(1)
    else:
        flash('Task not complete: ' + task.title)
        task.set_status(0)
    return redirect(url_for('view_project', project_key=project_key))
Exemplo n.º 4
0
def view_task(project_key, task_key):
    project = Project.get_project(project_key)
    if project is None:
        abort(404)
    task = Task.get_task(project, task_key)
    current_user_id = get_user(request, project_key)
    form = CommentForm(request.form)
    if request.method == 'POST' and form.validate():
        flash("Your comment was added")
        task.add_comment(form.comment.data, current_user_id)
        return redirect(
            url_for('view_task', project_key=project_key, task_key=task_key))
    return render_template('task.html', task=task, project=project, form=form)
Exemplo n.º 5
0
def edit_task(project_key, task_key):
    form = TaskForm(request.form)
    project = Project.get_project(project_key)
    if project is None:
        abort(404)
    task = Task.get_task(project, task_key)
    choices = [(p.id, p.name) for p in project.people]
    form.assigned_to.choices = choices
    if request.method == 'POST' and form.validate():
        flash("Task was updated")
        task.update(form.title.data, int(form.priority.data),
                    form.description.data, form.assigned_to.data)
        return redirect(
            url_for('view_task', project_key=project_key, task_key=task_key))
    form.title.data = task.title
    form.priority.data = str(task.priority)
    form.description.data = task.description
    form.assigned_to.data = task.assigned_to
    return render_template('edit_task.html',
                           task=task,
                           project=project,
                           form=form)