Example #1
0
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

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

    return redirect(url_for("tasks_index"))
Example #2
0
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"))
Example #3
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"))
Example #4
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))
Example #5
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"))
Example #6
0
def tasks_new():
    form = TaskFormBase(request.form)

    # Just for the record, I have no idea what I'm doing here
    # This is apparently how you get a custom number of fields
    # But I have no idea how to make a new version of the same form in case of failure
    class TaskForm(TaskFormBase):
        pass

    classes = Class.query.filter_by(account_id=current_user.id).all()
    for c in classes:
        setattr(TaskForm, str(c.id), BooleanField(c.name))

    # For some reason this doesn't copy errors
    new = TaskForm()
    new.name = form.name
    new.estimate = form.estimate

    # ...but this works anyhow
    if not new.validate():
        return render_template("tasks/new.html", form=new)

    t = Task(new.name.data)
    t.account_id = current_user.id
    t.estimate = (new.estimate.data)

    # Checking which classes were selected
    for field in new:
        try:
            # If short_name is int, this does not throw error and it is a booleanfield describing a class with the id short_name
            c = Class.query.get(int(field.short_name))
            if (field.data):
                t.classes.append(c)
        except ValueError:
            pass

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

    return redirect(url_for("tasks_details", task_id=t.id))
Example #7
0
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"))
Example #8
0
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))