コード例 #1
0
ファイル: views.py プロジェクト: perander/training-planner
def tasks_create():
    categories = get_all_categories()
    tasks = get_all_tasks()

    if request.method == "GET":
        return render_template("tasks/new.html",
                               form=TaskForm(),
                               categories=categories,
                               tasks=tasks)

    form = TaskForm(request.form)

    # TODO: multipleselectfield doesn't support form.validate, need custom validation
    # if not form.validate():
    #    return render_template("tasks/new.html", form=form)

    if form.is_submitted() and exists(form.name.data):
        return render_template("tasks/new.html",
                               form=form,
                               categories=categories,
                               tasks=tasks,
                               error="Task " + form.name.data +
                               " already exists")

    create(form.name.data, form.description.data, form.categories.data,
           form.subtasks.data)

    db.session().commit()

    return redirect(url_for("tasks_index"))
コード例 #2
0
ファイル: views.py プロジェクト: perander/training-planner
def tasks_update(task_id):
    task = find(task_id)

    if request.method == "GET":
        return render_template("tasks/updateform.html",
                               form=TaskForm(),
                               task=task,
                               categories=get_all_categories(),
                               tags=task.get_tags(),
                               subtasks=get_all_tasks(),
                               existing=task.get_subtasks())

    form = TaskForm(request.form)

    # TODO: validointi
    # if not form.validate():
    #   return render_template("tasks/update.html", form=form,
    #   task=task, categories=categories, tags=old_categories)

    if exists_another(task_id, form.name.data):
        return render_template("tasks/updateform.html",
                               form=form,
                               task=task,
                               categories=get_all_categories(),
                               tags=task.get_tags(),
                               subtasks=get_all_tasks(),
                               existing=task.get_subtasks(),
                               error="Task " + form.name.data +
                               " already exists")

    update(task_id, form.name.data, form.description.data,
           form.categories.data, form.subtasks.data)

    db.session().commit()
    return redirect(url_for("tasks_index"))
コード例 #3
0
def tasks_form():
    cat = session['category']
    form = TaskForm()    
    if cat != "none" and cat != "all":
        form.category.default = Category.query.get(cat)
    form.process()
    return render_template("tasks/new.html", form = form)
コード例 #4
0
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)
コード例 #5
0
ファイル: views.py プロジェクト: pekkaseppanen/todosovellus
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"))
コード例 #6
0
ファイル: views.py プロジェクト: Hannav/Matkapakkaaja
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))
コード例 #7
0
ファイル: views.py プロジェクト: strajama/tsoha-todolist
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"))
コード例 #8
0
def update_task(id_g):
	form = TaskForm(request.form)
	task = Task.query.get(id_g)
	task.name = form.name.data
	db.session().commit()
	
	return redirect(url_for('tasks_index'))
コード例 #9
0
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))
コード例 #10
0
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"))
コード例 #11
0
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"))
コード例 #12
0
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"))
コード例 #13
0
ファイル: views.py プロジェクト: tjvalkonen/tyoaikaseuranta
def tasks_index(project_id):
    return render_template(
        "tasks/list.html",
        tasks=Task.find_tasks_in_project(project_id),
        workdone=Project.work_done_in_project(project_id),
        workestimated=Project.work_estimated_in_project(project_id),
        project_id=project_id,
        form=TaskForm(),
        userworkdone=Project.work_done_in_project_by_user(project_id),
        userworkestimate=Project.work_estimated_in_project_by_user(project_id))
コード例 #14
0
ファイル: views.py プロジェクト: pe5/Usein-kysytyt-kysymykset
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"))
コード例 #15
0
ファイル: views.py プロジェクト: tjvalkonen/tyoaikaseuranta
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))
コード例 #16
0
ファイル: views.py プロジェクト: danieladasilva/Muistilista
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
    t.account_id = current_user.id
    t.group_id = form.groups.data

    db.session().add(t)
    db.session().commit()

    return redirect(url_for("tasks_index"))
コード例 #17
0
ファイル: views.py プロジェクト: pe5/Usein-kysytyt-kysymykset
def tasks_form():
    return render_template("tasks/new.html", form = TaskForm())
コード例 #18
0
ファイル: views.py プロジェクト: Hannav/Matkapakkaaja
def tasks_modify(task_id):
    
    task = Task.query.get(task_id)
    return render_template("tasks/modify.html", form = TaskForm(MultiDict([('name', task.name), ('done', task.done)])), task_id=task_id)
コード例 #19
0
ファイル: views.py プロジェクト: Hannav/Matkapakkaaja
def tasks_form(trip_id):
    return render_template("tasks/new.html", form = TaskForm(), trip_id=trip_id)
コード例 #20
0
def tasks_form():
    categories = [(category.id, category.name)
                  for category in Category.query.all()]
    form = TaskForm()
    form.tasks_and_categories.choices = categories
    return render_template("tasks/new.html", form=form)
コード例 #21
0
def tasks_form(project_id):
    return render_template('tasks/new_task.html',
                           form=TaskForm(),
                           project_id=project_id)
コード例 #22
0
def edit_task(id_g):
	form = TaskForm(request.form)
	form.name.data = Task.query.get(id_g).name
	return render_template("tasks/edit.html", task = Task.query.get(id_g), form = form)