def add(): form = TaskForm() if form.validate_on_submit(): new_task = Tasks(task=form.task.data) db.session.add(new_task) db.session.commit() return redirect(url_for('home')) return render_template('add.html', form=form)
def create(): form=TaskForm() if request.method == "POST": #(check to see if the method a post request.)post request: send the filled/complete info to the route if form.validate_on_submit():#check if the form validates new_task = Tasks(description = form.description.data) #check if new task has been added with the data db.session.add(new_task) # add the new task to the route db.session.commit() # commit to the data base itself return redirect(url_for("home")) #redirect back to the home page return render_template("add.html", title = "Create a Task", form=form)
def create(): form = TaskForm() if request.method == 'POST': if form.validate_on_submit(): new_task = Species(description=form.description.data) db.session.add(new_task) db.session.commit() return redirect(url_for('home')) return render_template('add.html', title='Create', form=form)
def create(): form = TaskForm() if request.method == "POST": if form.validate_on_submit(): new_task = Tasks(description=form.description.data) db.session.add(new_task) db.session.commit() return redirect(url_for("home")) return render_template("add.html", title="Create a Task", form=form)
def update(task_id): form = TaskForm() task_to_update = Tasks.query.get(task_id) if form.validate_on_submit(): task_to_update.task = form.task.data db.session.commit() return redirect(url_for('home')) elif request.method == 'GET': form.task.data = task_to_update.task return render_template('update.html', form=form)
def created(): form = TaskForm() if request.method == "POST": if form.validate_on_submit(): new_task = Task(description=form.description.data) print(new_task.complete) db.session.add(new_task) db.session.commit() return redirect(url_for('home')) return render_template('add.html', title="Create a Task", form=form)
def add(): form = TaskForm() if request.method == "POST": if form.validate_on_submit(): new_task = Tasks(task=form.task.data, status=form.status.data) db.session.add(new_task) db.session.commit() return redirect(url_for("home")) return render_template("add.html", title="Add Task", form=form)
def editList(list_name): if not listExists(list_name): return redirect(url_for("home")) list_id = getListId(list_name) message = "Add tasks!" error_text = "" task_input = TaskForm() if request.method == "POST" and task_input.validate_on_submit(): new_task = Task(name=task_input.user_input.data, list_id=list_id) db.session.add(new_task) db.session.commit() task_input.user_input.data = "" message = "task added!" else: if task_input.user_input.errors: error_text = task_input.user_input.errors[0] # Read task_details = {} for item in Task.query.all(): task_details[item.name] = [item.date_done] # Display config: done_tasks = doneTaskNames(list_id=list_id) non_done_tasks = notDoneTaskNames(list_id=list_id) if len(done_tasks) == 0: done_tasks_exists = False else: done_tasks_exists = True if len(non_done_tasks) == 0: non_done_tasks_exists = False else: non_done_tasks_exists = True return render_template("edit_list.html", list_name=list_name, non_done_tasks_exists=non_done_tasks_exists, non_done_tasks=non_done_tasks, form=task_input, task_details=task_details, done_tasks_exists=done_tasks_exists, done_tasks=done_tasks, message=message, error_text=error_text)
def update(id): form= TaskForm() task= Tasks.query.filter_by(id=id).first() if request.method =="POST": # id the form has been posted task.description = form.description.data db.session.commit() return redirect(url_for("home")) return render_template("update.html", form=form, title="Update Task", task=task)
def update(number): form = TaskForm() task = Tasks.query.filter_by(id=number).first() if request.method == 'POST': task.description = form.description.data db.session.commit() return redirect(url_for("home")) return render_template("update.html", form=form, title='Update', task=task)
def update(id): task = Tasks.query.filter_by(id=id).first() form = TaskForm() if request.method == "POST": task.desc = form.desc.data db.session.commit() return redirect(url_for('home')) return render_template("edit.html", form=form, title="Update Task", task=task)
def update(id): form = TaskForm() task = Species.query.filter_by(id=id).first() if request.method == 'POST': task.description = form.description.data db.session.commit() return redirect(url_for('home')) return render_template('update.html', form=form, title='Updated Task', task=task)
def addtask(id): project=Projects.query.filter_by(id=id) projectData = project.first() form = TaskForm() form.project_id.data=projectData.project_name if form.validate_on_submit(): taskData = Tasks( task_name=form.task_name.data, user=form.user.data, project_id=id, due_date=form.due_date.data, start_date=form.start_date.data, end_date=form.end_date.data, status=form.status.data, ) db.session.add(taskData) db.session.commit() return redirect(url_for('tasks')) else: print(form.errors) return render_template('addtask.html', title='Add Task', form=form)
def complete(number): form = TaskForm() task = Tasks.query.filter_by(id=number).first() task.complete = True db.session.commit() return redirect(url_for("home"))
def complete(id): task = tasks.query.filter_by(id=id).first() task.completed = True db.session.commit() return redirect(url_for("home")) @app.route("/incomplete/<int:id>", methods=["POST"]) def incomplete(id) task = tasks.query.filter_by(id=id).first() task.completed - False db.session.commit() return redirect(url_for("home")) @app.route("/update/<int:id>", methods=["GET", "POST"]) def update(id) form = TaskForm() task = Tasks.query.filter_by(id=id).first() if request.method == "POST": task.description = form.description.data db.session.commit() return redirect(url_for("home")) return render_template("update.html", form=form, title="Update Task", task=task) @app.route("/delete/<int:id>", methods=["GET","POST"]) def delete(id) task = tasks.query.filter_by(id=id).first() db.session.delete(task) db.session.commit return redirect(url_for("home"))