Add custom validator for multiple emails in a single text field. Change the widget of the email fields in the mailer app to avoid browser side email validation. Closes GitLab issue #530. Thanks to Mark Maglana @relaxdiego for the report.

Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
Roberto Rosario
2018-10-17 00:01:48 -04:00
parent cc79e75d35
commit 321b7ad5ae
7 changed files with 217 additions and 39 deletions

View File

@@ -18,6 +18,7 @@ from .settings import (
setting_document_body_template, setting_document_subject_template,
setting_link_body_template, setting_link_subject_template
)
from .validators import validate_email_multiple
class DocumentMailForm(forms.Form):
@@ -56,11 +57,11 @@ class DocumentMailForm(forms.Form):
except UserMailer.DoesNotExist:
pass
email = forms.EmailField(
email = forms.CharField(
help_text=_(
'Email address of the recipient. Can be multiple addresses '
'separated by comma or semicolon.'
), label=_('Email address')
), label=_('Email address'), validators=[validate_email_multiple]
)
subject = forms.CharField(label=_('Subject'), required=False)
body = forms.CharField(
@@ -117,4 +118,9 @@ class UserMailerDynamicForm(DynamicModelForm):
class UserMailerTestForm(forms.Form):
email = forms.EmailField(label=_('Email address'))
email = forms.CharField(
help_text=_(
'Email address of the recipient. Can be multiple addresses '
'separated by comma or semicolon.'
), label=_('Email address'), validators=[validate_email_multiple]
)