def edit(task_id): task = Task.query.get(task_id) if task: if task.account_id != current_user.id: return redirect('/tasks') form = TaskForm(formdata=request.form, obj=task) if request.method == 'POST' and form.validate(): task.deadline = form.deadline.data task.possible_after = form.possible_after.data task.name = form.name.data task.description = form.description.data if form.category.data: task.category_id = form.category.data.id db.session().commit() flash('Task updated successfully') return redirect('/tasks') return render_template('tasks/edit.html', form=form) else: return 'Error loading #{task_id}'.format(id=id)
def tasks_create(): form = TaskForm(request.form) if not form.validate(): return render_template("tasks/new.html", form = form) t = Task(form.name.data) t.done = form.done.data db.session().add(t) db.session().commit() return redirect(url_for("tasks_index"))
def tasks_create(trip_id): form = TaskForm(request.form) if not form.validate(): return render_template("tasks/new.html", form=form, trip_id=trip_id) t = Task(form.name.data, trip_id) t.done = form.done.data t.account_id = current_user.id db.session().add(t) db.session().commit() return redirect(url_for("trip_details", trip_id=trip_id))
def tasks_create(): form = TaskForm(request.form) if not form.validate(): return render_template("tasks/new.html", form=form) task = Task(form.name.data, form.description.data, form.estimated_time.data) task.used_time = 0 task.account_id = current_user.id task.username = current_user.name db.session().add(task) db.session().commit() return redirect(url_for("tasks_index"))
def create_tasks(): form = TaskForm(request.form) if not form.validate(): return render_template("tasks/create.html", form=form) t = Task(form.name.data, form.description.data, form.deadline.data) t.user_id = current_user.id labels = form.labels.data.split(",") for l in labels: t.labels.append(Label(l.strip())) db.session().add(t) db.session().commit() return redirect(url_for("tasks_index"))
def tasks_create(): form = TaskForm(request.form) form.tasks_and_categories.choices = [(category.id, category.name) for category in Category.query.all()] if not form.validate(): return render_template("tasks/new.html", form=form) t = Task(form.name.data, form.priority.data, Category.all_by_id(form.tasks_and_categories.data)) t.done = form.done.data t.account_id = current_user.id db.session().add(t) db.session().commit() return redirect(url_for("tasks_index"))
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) if not form.validate(): return render_template("tasks/new.html", form = form) dl = form.deadline.data pa = form.possible_after.data t = Task(form.name.data, form.description.data, dl, pa) t.account_id = current_user.id if(form.category.data): t.category_id = form.category.data.id db.session().add(t) db.session().commit() return redirect(url_for("tasks_index"))
def tasks_create(): form = TaskForm(request.form) if not form.validate(): return render_template("tasks/new.html", form = form) t = Task(form.name.data) t.done = form.answer.data t.account_id = current_user.id apu = Subject.find_id_of_subject(form.subject.data) if apu != -999: t.subject_id = apu else: s = Subject(form.subject.data) db.session().add(s) db.session().commit() apu2 = Subject.find_id_of_subject(form.subject.data) t.subject_id = apu2 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))