Esempio n. 1
0
def edit(id=None):

    objective = None
    if id:
        objective = get_objective_or_404(id=id)

    form = ObjectiveForm()

    if form.validate_on_submit():

        if objective:
            form.update(objective)
            flash('Updated objective')

        else:
            objective = form.create()
            flash('Added objective')

        return redirect(url_for('.view', id=objective.id))

    if objective:
        form.what.data = objective.entry.what
        form.how.data = objective.entry.how
        if 'progress' in objective.entry:
            form.progress.data = objective.entry.progress

    return render_template(
        'objectives/edit.html',
        form=form,
        objective=objective)
Esempio n. 2
0
def edit(id=None):

    objective = None
    if id:
        objective = get_objective_or_404(id=id)

    form = ObjectiveForm()

    if form.validate_on_submit():

        if objective:
            form.update(objective)
            flash('Updated objective')

        else:
            objective = form.create()
            flash('Added objective')

        return redirect(url_for('.view', id=objective.id))

    if objective:
        form.what.data = objective.entry.what
        form.how.data = objective.entry.how
        if 'measures' in objective.entry:
            form.measures.data = objective.entry.measures

        if 'outcomes' in objective.entry:
            form.outcomes.data = objective.entry.outcomes

        if 'deliverables' in objective.entry:
            form.deliverables.data = objective.entry.deliverables

        if 'progress' in objective.entry:
            form.progress.data = objective.entry.progress

    return render_template(
        'objectives/edit.html',
        form=form,
        objective=objective)