aboutsummaryrefslogtreecommitdiff
path: root/budget/web.py
diff options
context:
space:
mode:
authorAlexis Metaireau <alexis@notmyidea.org>2011-09-14 22:03:18 +0200
committerAlexis Metaireau <alexis@notmyidea.org>2011-09-14 22:03:18 +0200
commit20ab40690d74befcd8fc75f24f301759840bf43a (patch)
treed92319ad0f5cc6b6b506f8c918fd30549eb81b69 /budget/web.py
parent5721be1d15ba02e47f98fb9a487248adb297a082 (diff)
downloadihatemoney-mirror-20ab40690d74befcd8fc75f24f301759840bf43a.zip
ihatemoney-mirror-20ab40690d74befcd8fc75f24f301759840bf43a.tar.gz
ihatemoney-mirror-20ab40690d74befcd8fc75f24f301759840bf43a.tar.bz2
Provide a way to edit a project. Fix #17
Diffstat (limited to 'budget/web.py')
-rw-r--r--budget/web.py20
1 files changed, 19 insertions, 1 deletions
diff --git a/budget/web.py b/budget/web.py
index 7376135..250359d 100644
--- a/budget/web.py
+++ b/budget/web.py
@@ -7,7 +7,7 @@ import werkzeug
# local modules
from models import db, Project, Person, Bill
from forms import (ProjectForm, AuthenticationForm, BillForm, MemberForm,
- InviteForm, CreateArchiveForm)
+ InviteForm, CreateArchiveForm, EditProjectForm)
from utils import get_billform_for, Redirect303
"""
@@ -130,6 +130,24 @@ def create_project():
return render_template("create_project.html", form=form)
+@main.route("/<project_id>/edit", methods=["GET", "POST"])
+def edit_project():
+ form = EditProjectForm()
+ if request.method == "POST":
+ if form.validate():
+ project = form.update(g.project)
+ db.session.commit()
+ session[project.id] = project.password
+
+ return redirect(url_for(".list_bills"))
+ else:
+ form.name.data = g.project.name
+ form.password.data = g.project.password
+ form.contact_email.data = g.project.contact_email
+
+ return render_template("edit_project.html", form=form)
+
+
@main.route("/exit")
def exit():
# delete the session