aboutsummaryrefslogtreecommitdiff
path: root/budget/forms.py
diff options
context:
space:
mode:
authorAlexis Metaireau <alexis@notmyidea.org>2011-10-08 13:45:05 +0200
committerAlexis Metaireau <alexis@notmyidea.org>2011-10-08 13:45:05 +0200
commit19ae3ab3b2af98c5e39e8a73dc9b5d973dda5aa3 (patch)
treecc018b121b7b6965f3cb9ab2dc57c8ec01090fb3 /budget/forms.py
parent48bc551853b8b0067cdaeef98b3e454c3249f98f (diff)
downloadihatemoney-mirror-19ae3ab3b2af98c5e39e8a73dc9b5d973dda5aa3.zip
ihatemoney-mirror-19ae3ab3b2af98c5e39e8a73dc9b5d973dda5aa3.tar.gz
ihatemoney-mirror-19ae3ab3b2af98c5e39e8a73dc9b5d973dda5aa3.tar.bz2
merge with master
Diffstat (limited to 'budget/forms.py')
-rw-r--r--budget/forms.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/budget/forms.py b/budget/forms.py
index 25731bc..499f382 100644
--- a/budget/forms.py
+++ b/budget/forms.py
@@ -1,4 +1,6 @@
from flaskext.wtf import *
+from flask import request
+
from wtforms.widgets import html_params
from models import Project, Person, Bill, db
from datetime import datetime
@@ -20,14 +22,14 @@ def select_multi_checkbox(field, ul_class='', **kwargs):
return u''.join(html)
-def get_billform_for(request, project, set_default=True):
+def get_billform_for(project, set_default=True, **kwargs):
"""Return an instance of BillForm configured for a particular project.
:set_default: if set to True, on GET methods (usually when we want to
display the default form, it will call set_default on it.
"""
- form = BillForm()
+ form = BillForm(**kwargs)
form.payed_for.choices = form.payer.choices = [(str(m.id), m.name) for m in project.active_members]
form.payed_for.default = [str(m.id) for m in project.active_members]
@@ -36,6 +38,7 @@ def get_billform_for(request, project, set_default=True):
return form
+
class EditProjectForm(Form):
name = TextField("Project name", validators=[Required()])
password = TextField("Private code", validators=[Required()])
@@ -71,10 +74,8 @@ class ProjectForm(EditProjectForm):
if Project.query.get(form.id.data):
raise ValidationError(Markup("""The project identifier is used
to log in and for the URL of the project.
- <br />
We tried to generate an identifier for you but
a project with this identifier already exists.
- <br />
Please create a new identifier you will be able
to remember.
"""))