-
Notifications
You must be signed in to change notification settings - Fork 0
/
forms.py
43 lines (28 loc) · 1.47 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
from flask_wtf import FlaskForm
from wtforms import StringField, PasswordField, TextAreaField
from wtforms.validators import DataRequired, Email, Length, Optional
class MessageForm(FlaskForm):
"""Form for adding/editing messages."""
text = TextAreaField('text', validators=[DataRequired()])
class CommentForm(FlaskForm):
"""Form for adding/editing messages."""
text = TextAreaField('text', validators=[DataRequired()])
class UserAddForm(FlaskForm):
"""Form for adding users."""
username = StringField('Username', validators=[DataRequired()])
email = StringField('E-mail', validators=[DataRequired(), Email()])
password = PasswordField('Password', validators=[Length(min=6)])
image_url = StringField('(Optional) Image URL')
class EditUserForm(FlaskForm):
"""Form for editing user's profile."""
username = StringField('Username', validators=[DataRequired()])
email = StringField('E-mail', validators=[DataRequired(), Email()])
bio = TextAreaField('Bio', validators=[Optional(), Length(max=300)])
location = StringField('Location', validators=[Optional()])
image_url = StringField('(Optional) Profile Image URL')
header_image_url = StringField('(Optional) Header Image URL')
password = PasswordField('Password', validators=[Length(min=6)])
class LoginForm(FlaskForm):
"""Login form."""
username = StringField('Username', validators=[DataRequired()])
password = PasswordField('Password', validators=[Length(min=6)])