diff options
| author | Alexis Metaireau <alexis@notmyidea.org> | 2019-01-03 13:29:56 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-01-03 13:29:56 +0100 |
| commit | d55b9961704f913312ae17f837f62d1822802ecf (patch) | |
| tree | 02bc27f0b6ffdaf15a08b651d2953f35356c0148 /ihatemoney/forms.py | |
| parent | 04adfe4155e1bb37609edfe78ae67b361f51e0cf (diff) | |
| download | ihatemoney-mirror-d55b9961704f913312ae17f837f62d1822802ecf.zip ihatemoney-mirror-d55b9961704f913312ae17f837f62d1822802ecf.tar.gz ihatemoney-mirror-d55b9961704f913312ae17f837f62d1822802ecf.tar.bz2 | |
Do not allow negative weights on users (Fixes #362) (#366)
Diffstat (limited to 'ihatemoney/forms.py')
| -rw-r--r-- | ihatemoney/forms.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/ihatemoney/forms.py b/ihatemoney/forms.py index 5374fd9..be04c8f 100644 --- a/ihatemoney/forms.py +++ b/ihatemoney/forms.py @@ -2,7 +2,7 @@ from flask_wtf.form import FlaskForm from wtforms.fields.core import SelectField, SelectMultipleField from wtforms.fields.html5 import DateField, DecimalField from wtforms.fields.simple import PasswordField, SubmitField, TextAreaField, StringField -from wtforms.validators import Email, Required, ValidationError, EqualTo +from wtforms.validators import Email, Required, ValidationError, EqualTo, NumberRange from flask_babel import lazy_gettext as _ from flask import request from werkzeug.security import generate_password_hash @@ -174,9 +174,11 @@ class BillForm(FlaskForm): class MemberForm(FlaskForm): - name = StringField(_("Name"), validators=[Required()]) - weight = CommaDecimalField(_("Weight"), default=1) + + weight_validators = [NumberRange(min=0.1, message=_("Weights should be positive"))] + weight = CommaDecimalField(_("Weight"), default=1, + validators=weight_validators) submit = SubmitField(_("Add")) def __init__(self, project, edit=False, *args, **kwargs): |
