-
Notifications
You must be signed in to change notification settings - Fork 0
/
forms.py
33 lines (26 loc) · 1.39 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
from flask_wtf import FlaskForm
from wtforms import StringField, SubmitField, PasswordField, EmailField
from wtforms.validators import DataRequired, URL
from flask_ckeditor import CKEditorField
# WTForm for creating a blog post
class CreatePostForm(FlaskForm):
title = StringField("Blog Post Title", validators=[DataRequired()])
subtitle = StringField("Subtitle", validators=[DataRequired()])
img_url = StringField("Blog Image URL", validators=[DataRequired(), URL()])
body = CKEditorField("Blog Content", validators=[DataRequired()])
submit = SubmitField("Submit Post")
# TODO: Create a RegisterForm to register new users
class RegisterForm(FlaskForm):
email = EmailField(label='Email', validators=[DataRequired()])
password = PasswordField(label='Password', validators=[DataRequired()])
name = StringField(label='Name', validators=[DataRequired()])
submit = SubmitField(label='SIGN ME UP!')
# TODO: Create a LoginForm to login existing users
class LoginForm(FlaskForm):
email = StringField(label='Email', validators=[DataRequired()])
password = PasswordField(label='Password', validators=[DataRequired()])
submit = SubmitField(label='Login')
# TODO: Create a CommentForm so users can leave comments below posts
class CommentForm(FlaskForm):
editor = CKEditorField(label='Comment', validators=[DataRequired()])
submit = SubmitField(label='Submit Comment')