aboutsummaryrefslogtreecommitdiff
path: root/budget/forms.py
diff options
context:
space:
mode:
Diffstat (limited to 'budget/forms.py')
-rw-r--r--budget/forms.py25
1 files changed, 18 insertions, 7 deletions
diff --git a/budget/forms.py b/budget/forms.py
index a81d8ca..4699531 100644
--- a/budget/forms.py
+++ b/budget/forms.py
@@ -50,17 +50,28 @@ class BillForm(Form):
amount = DecimalField("Amount payed", validators=[Required()])
payed_for = SelectMultipleField("Who has to pay for this?",
validators=[Required()], widget=select_multi_checkbox)
- submit = SubmitField("Add the bill")
+ submit = SubmitField("Send the bill")
- def save(self):
- bill = Bill(payer_id=self.payer.data, amount=self.amount.data,
- what=self.what.data, date=self.date.data)
- # set the owers
- for ower in self.payed_for.data:
- bill.owers.append(Person.query.get(ower))
+ def save(self, bill):
+ bill.payer_id=self.payer.data
+ bill.amount=self.amount.data
+ bill.what=self.what.data
+ bill.date=self.date.data
+ bill.owers = [Person.query.get(ower) for ower in self.payed_for.data]
+ print self.payed_for.data
return bill
+ def fill(self, bill):
+ self.payer.data = bill.payer_id
+ self.amount.data = bill.amount
+ self.what.data = bill.what
+ self.date.data = bill.date
+ self.payed_for.data = [str(ower.id) for ower in bill.owers]
+
+ def set_default(self):
+ self.payed_for.data = self.payed_for.default
+
class MemberForm(Form):
def __init__(self, project, *args, **kwargs):