Update forms.py to finish field mixin refactoring, and add missing email validator

This commit is contained in:
Kyle J. Roux 2017-05-19 22:19:25 -07:00
parent 76c77a6b12
commit 9525da85ac

View File

@ -10,10 +10,18 @@ class EmailFieldMixin(Form):
'Email',
validators=[
DataRequired(),
Email()
Email(),
Length(1, 254, 'Too long.'),
]
)
class PasswordConfirmFieldMixin(Form):
"""
mixin class to provide extra password field
"""
password_confirm = PasswordField('Repeat password')
class PasswordFieldMixin(Form):
"""
mixin class to provide password field
@ -43,7 +51,7 @@ class LoginForm(FlaskForm, EmailFieldMixin, PasswordFieldMixin):
Form Login
'''
class SignupForm(FlaskForm, EmailFieldMixin, PasswordFieldMixin):
class SignupForm(FlaskForm, EmailFieldMixin, PasswordConfirmFieldMixin, PasswordFieldMixin):
'''
Form signup
'''
@ -58,7 +66,6 @@ class SignupForm(FlaskForm, EmailFieldMixin, PasswordFieldMixin):
)
]
)
password_confirm = PasswordField('Repeat password')
accept_tos = BooleanField(
'I accept the terms and conditions.',
validators=[
@ -75,8 +82,8 @@ class EmailResetPasswordForm(FlaskForm, EmailFieldMixin):
Form send email reset password
'''
class ResetPasswordForm(FlaskForm):
class ResetPasswordForm(FlaskForm,PasswordConfirmFieldMixin):
'''
Form update password
'''
password_confirm = PasswordField('Repeat password')