-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathforms.py
More file actions
50 lines (44 loc) · 2.3 KB
/
forms.py
File metadata and controls
50 lines (44 loc) · 2.3 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# Importing necessary classes and libraries from Flask-WTF and WTForms
from flask_wtf import FlaskForm
from wtforms import StringField, SubmitField, PasswordField
from wtforms.validators import DataRequired, URL
from flask_ckeditor import CKEditorField
# Form for creating a new blog post
class CreatePostForm(FlaskForm):
# Field for the post title with a validator to ensure it's not empty
title = StringField("Blog Post Title", validators=[DataRequired()])
# Field for the subtitle with a validator to ensure it's not empty
subtitle = StringField("Subtitle", validators=[DataRequired()])
# Field for the blog image URL with a validator to ensure it's not empty and a valid URL
img_url = StringField("Blog Image URL", validators=[DataRequired(), URL()])
# Field for the blog content using CKEditor to allow rich text formatting
body = CKEditorField("Blog Content", validators=[DataRequired()])
# Submit button for the blog post
submit = SubmitField("Submit Post")
# Form for registering new users
class RegisterForm(FlaskForm):
# Field for email with a validator to ensure it's not empty
email = StringField("Email", validators=[DataRequired()])
# Field for password with a validator to ensure it's not empty
password = PasswordField("Password", validators=[DataRequired()])
# Field for name with a validator to ensure it's not empty
name = StringField("Name", validators=[DataRequired()])
# Submit button for registration
submit = SubmitField("Sign Me Up!")
# Form for user login
class LoginForm(FlaskForm):
# Field for email with a validator to ensure it's not empty
email = StringField("Email", validators=[DataRequired()])
# Field for password with a validator to ensure it's not empty
password = PasswordField("Password", validators=[DataRequired()])
# Submit button for login
submit = SubmitField("Let Me In!")
# Form for commenting on blog posts
class CommentForm(FlaskForm):
# Field for comment text using CKEditor for rich text formatting
comment_text = CKEditorField("Comment", validators=[DataRequired()])
# Submit button for the comment
submit = SubmitField("Submit Comment")
class CommentForm(FlaskForm):
comment_text = CKEditorField("Comment", validators=[DataRequired()])
submit = SubmitField("Submit Comment")