mirror of
https://github.com/YunoHost-Apps/ihatemoney_ynh.git
synced 2024-09-03 19:26:15 +02:00
Part of a fix to #62 : french numbers should use commas rather than dots
This commit is contained in:
parent
342a80e225
commit
94ab8fbcc3
1 changed files with 9 additions and 2 deletions
|
@ -45,6 +45,11 @@ def get_billform_for(project, set_default=True, **kwargs):
|
||||||
form.set_default()
|
form.set_default()
|
||||||
return form
|
return form
|
||||||
|
|
||||||
|
class CommaDecimalField(DecimalField):
|
||||||
|
"""A class to deal with comma in Decimal Field"""
|
||||||
|
def process_formdata(self, value):
|
||||||
|
value[0] = str(value[0]).replace(',', '.')
|
||||||
|
return super(CommaDecimalField, self).process_formdata(value)
|
||||||
|
|
||||||
|
|
||||||
class EditProjectForm(Form):
|
class EditProjectForm(Form):
|
||||||
|
@ -102,7 +107,7 @@ class BillForm(Form):
|
||||||
date = DateField(_("Date"), validators=[Required()], default=datetime.now)
|
date = DateField(_("Date"), validators=[Required()], default=datetime.now)
|
||||||
what = TextField(_("What?"), validators=[Required()])
|
what = TextField(_("What?"), validators=[Required()])
|
||||||
payer = SelectField(_("Payer"), validators=[Required()], coerce=int)
|
payer = SelectField(_("Payer"), validators=[Required()], coerce=int)
|
||||||
amount = DecimalField(_("Amount paid"), validators=[Required()])
|
amount = CommaDecimalField(_("Amount paid"), validators=[Required()])
|
||||||
payed_for = SelectMultipleField(_("For whom?"),
|
payed_for = SelectMultipleField(_("For whom?"),
|
||||||
validators=[Required()], widget=select_multi_checkbox, coerce=int)
|
validators=[Required()], widget=select_multi_checkbox, coerce=int)
|
||||||
submit = SubmitField(_("Send the bill"))
|
submit = SubmitField(_("Send the bill"))
|
||||||
|
@ -129,7 +134,9 @@ class BillForm(Form):
|
||||||
|
|
||||||
def validate_amount(self, field):
|
def validate_amount(self, field):
|
||||||
if field.data < 0:
|
if field.data < 0:
|
||||||
raise ValidationError(_("Bills can't be negative"))
|
field.data = abs(field.data)
|
||||||
|
elif field.data == 0:
|
||||||
|
raise ValidationError(_("Bills can't be null"))
|
||||||
|
|
||||||
|
|
||||||
class MemberForm(Form):
|
class MemberForm(Form):
|
||||||
|
|
Loading…
Reference in a new issue