aboutsummaryrefslogtreecommitdiff
path: root/budget/web.py
diff options
context:
space:
mode:
authorArnaud Bos <arnaud.tlse@gmail.com>2011-09-11 05:25:42 +0200
committerArnaud Bos <arnaud.tlse@gmail.com>2011-09-11 05:30:28 +0200
commit88cd2f86751621d73574ac56a9d6c4bedcbdd3d5 (patch)
tree14a232f3be23e5785c3b9b37e6d05fbed8d0907f /budget/web.py
parentf48fc22335f1011bcf376a4f266a35a888f47b2e (diff)
downloadihatemoney-mirror-88cd2f86751621d73574ac56a9d6c4bedcbdd3d5.zip
ihatemoney-mirror-88cd2f86751621d73574ac56a9d6c4bedcbdd3d5.tar.gz
ihatemoney-mirror-88cd2f86751621d73574ac56a9d6c4bedcbdd3d5.tar.bz2
Fix #24 on Authentication and New project forms usability.
- Do not display anymore the identifier field in home. - Let the user enter the id if the slug generated from project name already exists as a project id. - Moved get_billform_for from 'utils' to 'forms', to avoid issue (was 'from forms import ...' into utils, and 'from utils import ...' into forms, which causeed an error).
Diffstat (limited to 'budget/web.py')
-rw-r--r--budget/web.py18
1 files changed, 12 insertions, 6 deletions
diff --git a/budget/web.py b/budget/web.py
index f72a686..cb8c4ac 100644
--- a/budget/web.py
+++ b/budget/web.py
@@ -5,9 +5,9 @@ from flaskext.mail import Mail, Message
# local modules
from models import db, Project, Person, Bill
-from forms import (ProjectForm, AuthenticationForm, BillForm, MemberForm,
- InviteForm, CreateArchiveForm)
-from utils import get_billform_for, Redirect303
+from forms import (get_billform_for, ProjectForm, AuthenticationForm, BillForm,
+ MemberForm, InviteForm, CreateArchiveForm)
+from utils import Redirect303
"""
The blueprint for the web interface.
@@ -111,6 +111,12 @@ def create_project():
form.name.data = request.values['project_id']
if request.method == "POST":
+ # At first, we don't want the user to bother with the identifier
+ # so it will automatically be missing because not displayed into the form
+ # Thus we fill it with the same value as the filled name, the validation will
+ # take care of the slug
+ if not form.id.data:
+ form.id.data = form.name.data
if form.validate():
# save the object in the db
project = form.save()
@@ -178,7 +184,7 @@ def list_bills():
bills = g.project.get_bills()
return render_template("list_bills.html",
bills=bills, member_form=MemberForm(g.project),
- bill_form=get_billform_for(g.project)
+ bill_form=get_billform_for(request, g.project)
)
@main.route("/<project_id>/members/add", methods=["GET", "POST"])
@@ -224,7 +230,7 @@ def remove_member(member_id):
@main.route("/<project_id>/add", methods=["GET", "POST"])
def add_bill():
- form = get_billform_for(g.project)
+ form = get_billform_for(request, g.project)
if request.method == 'POST':
if form.validate():
bill = Bill()
@@ -250,7 +256,7 @@ def delete_bill(bill_id):
@main.route("/<project_id>/edit/<int:bill_id>", methods=["GET", "POST"])
def edit_bill(bill_id):
bill = Bill.query.get_or_404(bill_id)
- form = get_billform_for(g.project, set_default=False)
+ form = get_billform_for(request, g.project, set_default=False)
if request.method == 'POST' and form.validate():
form.save(bill)
db.session.commit()