From b88b317faa8b462c3c932ed59903122a580ae825 Mon Sep 17 00:00:00 2001 From: Alexis Metaireau Date: Tue, 18 Oct 2011 18:13:54 +0200 Subject: [PATCH] Bills can't be negative. Fix #45 --- budget/forms.py | 4 ++++ budget/messages.pot | 3 +++ budget/tests.py | 9 +++++++++ .../translations/fr/LC_MESSAGES/messages.mo | Bin 7213 -> 7305 bytes .../translations/fr/LC_MESSAGES/messages.po | 3 +++ 5 files changed, 19 insertions(+) diff --git a/budget/forms.py b/budget/forms.py index 5abbd84..d0a60ca 100644 --- a/budget/forms.py +++ b/budget/forms.py @@ -120,6 +120,10 @@ class BillForm(Form): def set_default(self): self.payed_for.data = self.payed_for.default + def validate_amount(self, field): + if field.data < 0: + raise ValidationError(_("Bills can't be negative")) + class MemberForm(Form): diff --git a/budget/messages.pot b/budget/messages.pot index b8de26f..ef1fe23 100644 --- a/budget/messages.pot +++ b/budget/messages.pot @@ -445,3 +445,6 @@ msgstr "" msgid "each" msgstr "" + +msgid "Bills can't be negative" +msgstr "" diff --git a/budget/tests.py b/budget/tests.py index 0caf186..452f71f 100644 --- a/budget/tests.py +++ b/budget/tests.py @@ -283,6 +283,15 @@ class BudgetTestCase(TestCase): bill = models.Bill.query.one() self.assertEqual(bill.amount, 25) + self.app.post("/raclette/add", data={ + 'date': '2011-08-10', + 'what': u'fromage à raclette', + 'payer': members_ids[0], + 'payed_for': members_ids, + 'amount': '-25', # bill with a negative value is not possible + }) + self.assertEqual(1, models.Bill.query.count()) + # edit the bill resp = self.app.post("/raclette/edit/%s" % bill.id, data={ 'date': '2011-08-10', diff --git a/budget/translations/fr/LC_MESSAGES/messages.mo b/budget/translations/fr/LC_MESSAGES/messages.mo index c3b07a9197c53709a8f5a089be429d5feadc046f..62efe515edae4e506d09057f32d745154cabd589 100644 GIT binary patch delta 1819 zcmYM!TS!zv9LMp|%1dRs+N!l>r>hECpjZ}BWEY{N9xN-mvASCbx=F55p&Y0nyI>EM zSkb+pBrTL8$fz(WBIsT(A(#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Tmm^HP;STe)-^!P6B;Z+QS6^ZV_6O5Jt^eqh XQ^)pCZJXY(zJF&&@3DqiuQ&Yz*-V{4 diff --git a/budget/translations/fr/LC_MESSAGES/messages.po b/budget/translations/fr/LC_MESSAGES/messages.po index 0f021eb..e6232c0 100644 --- a/budget/translations/fr/LC_MESSAGES/messages.po +++ b/budget/translations/fr/LC_MESSAGES/messages.po @@ -451,3 +451,6 @@ msgstr "et les notifier vous même" msgid "each" msgstr "chacun" + +msgid "Bills can't be negative" +msgstr "Le montant d'une facture ne peut pas être négatif"