aboutsummaryrefslogtreecommitdiff
path: root/budget/forms.py
diff options
context:
space:
mode:
Diffstat (limited to 'budget/forms.py')
-rw-r--r--budget/forms.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/budget/forms.py b/budget/forms.py
index 0d9dae5..9abbb16 100644
--- a/budget/forms.py
+++ b/budget/forms.py
@@ -1,7 +1,6 @@
from flaskext.wtf import *
-from models import Project, Person
+from models import Project, Person, Bill
-# define forms
class ProjectForm(Form):
name = TextField("Project name", validators=[Required()])
id = TextField("Project identifier", validators=[Required()])
@@ -34,6 +33,15 @@ class BillForm(Form):
validators=[Required()])
submit = SubmitField("Add the bill")
+ def save(self):
+ bill = Bill(payer_id=self.payer.data, amount=self.amount.data,
+ what=self.what.data)
+ # set the owers
+ for ower in self.payed_for.data:
+ bill.owers.append(Person.query.get(ower))
+
+ return bill
+
class MemberForm(Form):
def __init__(self, project, *args, **kwargs):
@@ -48,6 +56,7 @@ class MemberForm(Form):
.filter(Person.project == form.project).all():
raise ValidationError("This project already have this member")
+
class InviteForm(Form):
emails = TextAreaField("People to notify")
submit = SubmitField("Send invites")