def add_task(project_title): form = AddTaskForm() if form.validate_on_submit(): if Task.find_by_title(form.title.data, current_user.user_id) == None: project = Project.find_by_title(project_title, current_user.user_id) task = Task(title=form.title.data, description=form.description.data, project_id=project.project_id, user_id=current_user.user_id) task.save_to_db() return redirect(url_for("tasks.overview", title=task.title)) return render_template("tasks/add.html", form=form, project_title=project_title, action="create")
def add_task_comment(task_title): form = AddCommentForm() if form.validate_on_submit(): task = Task.find_by_title(task_title, current_user.user_id) comment = TaskComment(task.task_id, current_user.user_id, form.comment.data) comment.save_to_db() return redirect(url_for("tasks.overview", title=task_title)) return render_template("comments/add.html", form=form, title=task_title, action="create")
def add(task_title): form = AddItemForm() if form.validate_on_submit(): if not Item.find_by_title(form.title.data, current_user.user_id): task = Task.find_by_title(task_title, current_user.user_id) item = Item(title=form.title.data, description=form.description.data, task_id=task.task_id, user_id=current_user.user_id) item.save_to_db() return redirect(url_for("items.overview", title=item.title)) return render_template("items/add.html", form=form, task_title=task_title, action="create")
def test_task(self): self.create_user(user_name="testuser", email="*****@*****.**", password="******") self.create_project(title="test_project", description="A test project", user_id=1) self.create_task(title="test_task", description="A test task", project_id=1, user_id=1) task = Task.find_by_title("test_task", 1) self.assertEquals(task.task_id, 1) self.assertEquals(task.description, "A test task") self.assertEquals(task.status_id, 1)
def update(title): form = AddTaskForm() form.submit.label.text = "Update" task = Task.find_by_title(title, current_user.user_id) if form.validate_on_submit(): task.title = form.title.data task.description = form.description.data task.save_to_db() return redirect(url_for("tasks.overview", title=task.title)) elif request.method == "GET": form.title.data = title form.description.data = task.description return render_template("tasks/add.html", form=form, project_title=task.project.title, action="update")
def create_task(self, title, description, project_id, user_id): task = Task(title=title, description=description, project_id=project_id, user_id=user_id) task.save_to_db()
def delete(title): task = Task.find_by_title(title, current_user.user_id) project = task.project task.delete() return redirect(url_for("projects.overview", title=project.title))
def overview(title): task = Task.find_by_title(title, current_user.user_id) return render_template("tasks/overview.html", task=task)