From fe0b292d452c0b54386c169899ffec4517becb7d Mon Sep 17 00:00:00 2001 From: Pierre Jaury Date: Tue, 14 Feb 2017 21:37:51 +0100 Subject: [PATCH] Handle infinite quotas when adding validators, fixes #162 --- admin/mailu/admin/views/users.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/admin/mailu/admin/views/users.py b/admin/mailu/admin/views/users.py index b7647138..0d086e23 100644 --- a/admin/mailu/admin/views/users.py +++ b/admin/mailu/admin/views/users.py @@ -22,8 +22,9 @@ def user_create(domain_name): return flask.redirect( flask.url_for('.user_list', domain_name=domain.name)) form = forms.UserForm() - form.quota_bytes.validators = [ - wtforms.validators.NumberRange(max=domain.max_quota_bytes)] + if domain.max_quota_bytes: + form.quota_bytes.validators = [ + wtforms.validators.NumberRange(max=domain.max_quota_bytes)] if form.validate_on_submit(): if domain.has_email(form.localpart.data): flask.flash('Email is already used', 'error') @@ -53,8 +54,9 @@ def user_edit(user_email): wtforms_components.read_only(form.localpart) form.pw.validators = [] form.localpart.validators = [] - form.quota_bytes.validators = [ - wtforms.validators.NumberRange(max=max_quota_bytes)] + if max_quota_bytes: + form.quota_bytes.validators = [ + wtforms.validators.NumberRange(max=max_quota_bytes)] if form.validate_on_submit(): form.populate_obj(user) if form.pw.data: