mirror of
https://github.com/rmontanana/microblog.git
synced 2025-08-17 00:05:51 +00:00
Chapter 6
This commit is contained in:
22
app/forms.py
22
app/forms.py
@@ -1,6 +1,18 @@
|
||||
from flask_wtf import FlaskForm
|
||||
from wtforms import StringField, PasswordField, BooleanField, SubmitField
|
||||
from wtforms.validators import DataRequired, EqualTo, Email, ValidationError
|
||||
from wtforms import (
|
||||
StringField,
|
||||
PasswordField,
|
||||
BooleanField,
|
||||
SubmitField,
|
||||
TextAreaField,
|
||||
)
|
||||
from wtforms.validators import (
|
||||
DataRequired,
|
||||
EqualTo,
|
||||
Email,
|
||||
ValidationError,
|
||||
Length,
|
||||
)
|
||||
from app.models import User
|
||||
|
||||
|
||||
@@ -29,3 +41,9 @@ class RegistrationForm(FlaskForm):
|
||||
user = User.query.filter_by(email=email.data).first()
|
||||
if user is not None:
|
||||
raise ValidationError("Please use a different email address.")
|
||||
|
||||
|
||||
class EditProfileForm(FlaskForm):
|
||||
username = StringField("Username", validators=[DataRequired()])
|
||||
about_me = TextAreaField("About me", validators=[Length(min=0, max=140)])
|
||||
submit = SubmitField("Submit")
|
||||
|
Reference in New Issue
Block a user