def tasks_create(): lomake = TehtäväLomake(request.form) lomake.apu.choices = [(l.id, l.nimi) for l in Luokka.query.all()] if not lomake.validate(): return render_template("tasks/new.html", lomake = lomake) t = Task(lomake.nimi.data, Luokka.all_by_id(lomake.apu.data)) t.done = lomake.tehty.data t.urgent = lomake.kiireellisyys.data t.time = lomake.aikavaatimus.data t.kayttaja_id = current_user.id db.session().add(t) db.session().commit() return redirect(url_for("tasks_index"))
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))