def tasks_create(project_id): project = Project.query.get(project_id) form = TaskForm(request.form) if not form.validate(): return render_template('tasks/new_task.html', form=form, project_id=project_id) new_task = Task(form.category.data, form.hours.data, form.description.data) new_task.project_id = project.id new_task.account_id = current_user.id current_user.tasks.append(new_task) project.tasks.append(new_task) db.session().add(new_task) db.session().add(current_user) db.session().add(project) db.session().commit() return redirect(url_for('tasks_index', project_id=project_id))
def tasks_create(): form = TaskForm(request.form) project_id = request.args.get('project_id') if not form.validate(): return render_template( "tasks/list.html", tasks=Task.find_tasks_in_project(project_id), workdone=Project.work_done_in_project(project_id), project_id=project_id, form=form) t = Task(form.tasktype.data) t.description = form.description.data t.time = form.time.data t.taskstatus = form.taskstatus.data t.project_id = project_id t.account_id = current_user.id db.session().add(t) db.session().commit() return redirect(url_for('tasks_index', project_id=project_id))