-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathforms.py
89 lines (73 loc) · 2.15 KB
/
forms.py
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
from flask_wtf import FlaskForm
from wtforms import StringField, PasswordField, TextAreaField
from wtforms.validators import DataRequired, Email, Length, URL, Optional
from email_validator import validate_email, EmailNotValidError
class MessageForm(FlaskForm):
"""Form for adding/editing messages."""
text = TextAreaField(
'text',
validators=[DataRequired(), Length(max=140)],
)
class UserAddForm(FlaskForm):
"""Form for adding users."""
username = StringField(
'Username',
validators=[DataRequired(), Length(max=20)],
)
email = StringField(
'E-mail',
validators=[DataRequired(), Email()],
)
password = PasswordField(
'Password',
validators=[Length(min=6, max=20)],
)
image_url = StringField(
'(Optional) Image URL',
validators=[Optional(), URL()],
)
class LoginForm(FlaskForm):
"""Login form."""
username = StringField(
'Username',
validators=[DataRequired(), Length(max=20)],
)
password = PasswordField(
'Password',
validators=[Length(min=6, max=20)],
)
class UserEditForm(FlaskForm):
""" Form for editing user info """
username = StringField(
'Username',
validators=[DataRequired(), Length(max=20)],
)
email = StringField(
'E-mail',
validators=[DataRequired(), Email()],
)
image_url = StringField(
'(Optional) Image URL',
validators=[Optional()],
)
header_image_url = StringField(
'(Optional) Header Image URL',
validators=[Optional()],
)
bio = TextAreaField(
'Bio',
render_kw={'class': 'form-control', 'rows': 10},
validators=[DataRequired()],
)
location = StringField(
'Location',
validators=[DataRequired(), Length(max=20)],
)
password = PasswordField(
'Password',
validators=[Length(min=6, max=20)]
)
class UserLogoutForm(FlaskForm):
""" Left empty for CSRF protection and caching. """
class UserMessageLikeForm(FlaskForm):
""" Left empty for CSRF protection and caching. """