Esempio n. 1
0
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)
Esempio n. 2
0
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)
Esempio n. 3
0
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)
Esempio n. 4
0
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)
Esempio n. 5
0
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)
Esempio n. 6
0
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)
Esempio n. 7
0
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)
Esempio n. 8
0
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)
Esempio n. 9
0
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)