aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexis Metaireau <alexis@notmyidea.org>2011-10-18 18:13:54 +0200
committerAlexis Metaireau <alexis@notmyidea.org>2011-10-18 18:13:54 +0200
commitb88b317faa8b462c3c932ed59903122a580ae825 (patch)
treeb6654438806a258ed642a3c30feefb8ef7962108
parent6e3834048b2b23a07afd5d2354b92131c2c175f9 (diff)
downloadihatemoney-mirror-b88b317faa8b462c3c932ed59903122a580ae825.zip
ihatemoney-mirror-b88b317faa8b462c3c932ed59903122a580ae825.tar.gz
ihatemoney-mirror-b88b317faa8b462c3c932ed59903122a580ae825.tar.bz2
Bills can't be negative. Fix #45
-rw-r--r--budget/forms.py4
-rw-r--r--budget/messages.pot3
-rw-r--r--budget/tests.py9
-rw-r--r--budget/translations/fr/LC_MESSAGES/messages.mobin7213 -> 7305 bytes
-rw-r--r--budget/translations/fr/LC_MESSAGES/messages.po3
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
index c3b07a9..62efe51 100644
--- a/budget/translations/fr/LC_MESSAGES/messages.mo
+++ b/budget/translations/fr/LC_MESSAGES/messages.mo
Binary files differ
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"