aboutsummaryrefslogtreecommitdiff
path: root/budget/forms.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/forms.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/forms.py')
-rw-r--r--budget/forms.py22
1 files changed, 13 insertions, 9 deletions
diff --git a/budget/forms.py b/budget/forms.py
index cfd5788..ceda0e7 100644
--- a/budget/forms.py
+++ b/budget/forms.py
@@ -18,16 +18,11 @@ def select_multi_checkbox(field, ul_class='', **kwargs):
return u''.join(html)
-class ProjectForm(Form):
+class EditProjectForm(Form):
name = TextField("Project name", validators=[Required()])
- id = TextField("Project identifier", validators=[Required()])
- password = PasswordField("Password", validators=[Required()])
+ password = TextField("Password", validators=[Required()])
contact_email = TextField("Email", validators=[Required(), Email()])
- submit = SubmitField("Create the project")
-
- def validate_id(form, field):
- if Project.query.get(field.data):
- raise ValidationError("This project id is already used")
+ submit = SubmitField("Edit the project")
def save(self):
"""Create a new project with the information given by this form.
@@ -42,12 +37,21 @@ class ProjectForm(Form):
def update(self, project):
"""Update the project with the information from the form"""
project.name = self.name.data
- project.id = self.id.data
project.password = self.password.data
project.contact_email = self.contact_email.data
return project
+class ProjectForm(EditProjectForm):
+ id = TextField("Project identifier", validators=[Required()])
+ password = PasswordField("Password", validators=[Required()])
+ submit = SubmitField("Create the project")
+
+ def validate_id(form, field):
+ if Project.query.get(field.data):
+ raise ValidationError("This project id is already used")
+
+
class AuthenticationForm(Form):
id = TextField("Project identifier", validators=[Required()])