-
Notifications
You must be signed in to change notification settings - Fork 3
/
forms.py
41 lines (33 loc) · 1.46 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
from flask_wtf import FlaskForm
from wtforms import StringField, SubmitField, PasswordField, validators
from wtforms.validators import DataRequired, URL
from flask_ckeditor import CKEditorField
from wtforms.fields.html5 import EmailField
# ----- SIGN UP FORM ----- #
class RegisterForm(FlaskForm):
email = EmailField("Email address", [
validators.DataRequired(), validators.Email()
])
password = PasswordField('Password', [
validators.DataRequired(),
validators.EqualTo('confirm', message='Passwords must match')
])
confirm = PasswordField('Repeat Password')
name = StringField("Name", [validators.Length(min=4, max=25)])
submit = SubmitField("Register")
# ----- LOGIN FORM ----- #
class LoginForm(FlaskForm):
email = StringField("Email", validators=[DataRequired()])
password = PasswordField("Password", validators=[DataRequired()])
submit = SubmitField("Login")
# ----- CREATE POST FORM ----- #
class CreatePostForm(FlaskForm):
title = StringField("Title", validators=[DataRequired()])
subtitle = StringField("Subtitle", validators=[DataRequired()])
img_url = StringField("Image URL", validators=[DataRequired(), URL()])
body = CKEditorField("What's on your mind...", validators=[DataRequired()])
submit = SubmitField("Publish")
# ----- COMMENT FORM ----- #
class CommentForm(FlaskForm):
comment_text = CKEditorField("Comment", validators=[DataRequired()])
submit = SubmitField("Submit Comment")