-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathForms.py
More file actions
30 lines (25 loc) · 1.77 KB
/
Forms.py
File metadata and controls
30 lines (25 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from flask_wtf import FlaskForm
from wtforms import StringField, SubmitField, BooleanField, PasswordField
from wtforms.validators import DataRequired, Email, Length, EqualTo
error_text_INVALID_EMAIL = 'Некорректный email'
error_text_PSW_LENGTH = 'Длина пароля должна быть от 4 до 100 символов'
error_text_NAME_LENGTH = 'Длина имени должна быть от 4 до 100 символов'
error_text_PSW_NOT_EQUAL = 'Пароли должны совпадать'
class LoginForm(FlaskForm):
email = StringField('Email: ', validators=[DataRequired(),
Email(error_text_INVALID_EMAIL)])
psw = PasswordField('Пароль: ', validators=[DataRequired(),
Length(min=4, max=100, message=error_text_PSW_LENGTH)])
remember = BooleanField('Запомнить', default=False)
submit = SubmitField('Войти')
class RegisterForm(FlaskForm):
name = StringField('Имя: ', validators=[DataRequired(),
Length(min=4, max=100, message=error_text_NAME_LENGTH)])
email = StringField('Email: ', validators=[DataRequired(),
Email(error_text_INVALID_EMAIL)])
psw = PasswordField('Пароль: ', validators=[DataRequired(),
Length(min=4, max=100, message=error_text_PSW_LENGTH)])
psw2 = PasswordField('Пароль: ', validators=[DataRequired(),
Length(min=4, max=100, message=error_text_PSW_LENGTH),
EqualTo('psw', message=error_text_PSW_NOT_EQUAL)])
submit = SubmitField('Регистрация')