diff options
| author | Alexis Metaireau <alexis@notmyidea.org> | 2011-10-18 18:13:54 +0200 |
|---|---|---|
| committer | Alexis Metaireau <alexis@notmyidea.org> | 2011-10-18 18:13:54 +0200 |
| commit | b88b317faa8b462c3c932ed59903122a580ae825 (patch) | |
| tree | b6654438806a258ed642a3c30feefb8ef7962108 /budget | |
| parent | 6e3834048b2b23a07afd5d2354b92131c2c175f9 (diff) | |
| download | ihatemoney-mirror-b88b317faa8b462c3c932ed59903122a580ae825.zip ihatemoney-mirror-b88b317faa8b462c3c932ed59903122a580ae825.tar.gz ihatemoney-mirror-b88b317faa8b462c3c932ed59903122a580ae825.tar.bz2 | |
Bills can't be negative. Fix #45
Diffstat (limited to 'budget')
| -rw-r--r-- | budget/forms.py | 4 | ||||
| -rw-r--r-- | budget/messages.pot | 3 | ||||
| -rw-r--r-- | budget/tests.py | 9 | ||||
| -rw-r--r-- | budget/translations/fr/LC_MESSAGES/messages.mo | bin | 7213 -> 7305 bytes | |||
| -rw-r--r-- | budget/translations/fr/LC_MESSAGES/messages.po | 3 |
5 files changed, 19 insertions, 0 deletions
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 Binary files differindex c3b07a9..62efe51 100644 --- a/budget/translations/fr/LC_MESSAGES/messages.mo +++ b/budget/translations/fr/LC_MESSAGES/messages.mo 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" |
