mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-21 08:29:27 -04:00
Use email fields for feedback form
Otherwise we can end up collecting invalid email addresses… This required some refactoring to allow our email fields to be optional (but not by default).
This commit is contained in:
@@ -110,15 +110,18 @@ class MultiCheckboxField(SelectMultipleField):
|
||||
option_widget = CheckboxInput()
|
||||
|
||||
|
||||
def email_address(label='Email address', gov_user=True):
|
||||
def email_address(label='Email address', gov_user=True, required=True):
|
||||
|
||||
validators = [
|
||||
Length(min=5, max=255),
|
||||
DataRequired(message='Can’t be empty'),
|
||||
ValidEmail()
|
||||
ValidEmail(),
|
||||
]
|
||||
|
||||
if gov_user:
|
||||
validators.append(ValidGovEmail())
|
||||
|
||||
if required:
|
||||
validators.append(DataRequired(message='Can’t be empty'))
|
||||
|
||||
return EmailField(label, validators)
|
||||
|
||||
|
||||
@@ -561,7 +564,7 @@ class SupportType(StripWhitespaceForm):
|
||||
|
||||
class Feedback(StripWhitespaceForm):
|
||||
name = StringField('Name')
|
||||
email_address = StringField('Email address')
|
||||
email_address = email_address(label='Email address', gov_user=False, required=False)
|
||||
feedback = TextAreaField('Your message', validators=[DataRequired(message="Can’t be empty")])
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user