Ejemplo n.º 1
0
def budget_edit(workspace, budget):
    form = BudgetForm(obj=budget)
    if form.validate_on_submit():
        form.populate_obj(budget)
        budget.make_name()
        db.session.commit()
        flash("Edited budget '%s'" % budget.title, "success")
        return render_redirect(url_for('budget', workspace=workspace.name, budget=budget.name), code=303)
    return render_form(form=form, title=u"Edit budget",
        formid='budget_edit', submit=u"Save",
        cancel_url=url_for('budget', workspace=workspace.name, budget=budget.name), ajax=True)
Ejemplo n.º 2
0
def budget_edit(name):
    budget = Budget.query.filter_by(name=name).first_or_404()
    form = BudgetForm(obj=budget)
    if form.validate_on_submit():
        form.populate_obj(budget)
        budget.make_name()
        db.session.commit()
        flash("Edited budget '%s'" % budget.title, "success")
        return render_redirect(url_for('budget', name=budget.name), code=303)
    return render_form(form=form, title=u"Edit budget",
        formid='budget_edit', submit=u"Save",
        cancel_url=url_for('budget', name=budget.name), ajax=True)
Ejemplo n.º 3
0
def budget_new(workspace):
    form = BudgetForm()
    if form.validate_on_submit():
        budget = Budget(workspace=workspace)
        form.populate_obj(budget)
        budget.make_name()
        db.session.add(budget)
        db.session.commit()
        flash("Created new budget '%s'." % budget.title, "success")
        return render_redirect(url_for('budget', workspace=workspace.name, budget=budget.name), code=303)
    return render_form(form=form, title=u"Create new budget",
        formid="budget_new", submit=u"Create",
        cancel_url=url_for('budget_list', workspace=workspace.name), ajax=True)
Ejemplo n.º 4
0
def budget_edit(name):
    budget = Budget.query.filter_by(name=name).first_or_404()
    form = BudgetForm(obj=budget)
    if form.validate_on_submit():
        form.populate_obj(budget)
        budget.make_name()
        db.session.commit()
        flash("Edited budget '%s'" % budget.title, "success")
        return render_redirect(url_for('budget', name=budget.name), code=303)
    return render_form(form=form,
                       title=u"Edit budget",
                       formid='budget_edit',
                       submit=u"Save",
                       cancel_url=url_for('budget', name=budget.name),
                       ajax=True)
Ejemplo n.º 5
0
def budget_new():
    form = BudgetForm()
    if form.validate_on_submit():
        budget = Budget()
        form.populate_obj(budget)
        budget.make_name()
        db.session.add(budget)
        db.session.commit()
        flash("Created new budget '%s'." % budget.title, "success")
        return render_redirect(url_for('budget', name=budget.name), code=303)
    return render_form(form=form,
                       title=u"Create new budget",
                       formid="budget_new",
                       submit=u"Create",
                       cancel_url=url_for('budget_list'),
                       ajax=True)
Ejemplo n.º 6
0
def budget_edit(workspace, budget):
    form = BudgetForm(obj=budget)
    if form.validate_on_submit():
        form.populate_obj(budget)
        budget.make_name()
        db.session.commit()
        flash("Edited budget '%s'" % budget.title, "success")
        return render_redirect(url_for('budget',
                                       workspace=workspace.name,
                                       budget=budget.name),
                               code=303)
    return render_form(form=form,
                       title=u"Edit budget",
                       formid='budget_edit',
                       submit=u"Save",
                       cancel_url=url_for('budget',
                                          workspace=workspace.name,
                                          budget=budget.name),
                       ajax=True)