-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathforms.py
50 lines (36 loc) · 1.95 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
44
45
46
47
48
49
50
import email_validator
from flask_wtf import FlaskForm
from wtforms import StringField, PasswordField
from flask_wtf.file import FileField, FileAllowed, FileRequired
from wtforms.validators import DataRequired, Email, Length
class SearchForm(FlaskForm):
"""Search form."""
search_term = StringField(
'Search for a Book, Author or Interest.', validators=[DataRequired()])
class AddUserForm(FlaskForm):
"""Form for adding users."""
username = StringField('Username', validators=[DataRequired()])
email = StringField('E-mail', validators=[DataRequired(), Email()])
password = PasswordField('Password', validators=[Length(min=6)])
first_name = StringField('First Name', validators=[DataRequired()])
last_name = StringField('Last Name', validators=[DataRequired()])
profile_pic = FileField('(Optional) Upload Image', validators=[
FileRequired("Please select a photo from your files"), FileAllowed(['jpg', 'png', 'jpeg'], 'Images only!')])
class LoginForm(FlaskForm):
"""Login form."""
username = StringField('Username', validators=[DataRequired()])
password = PasswordField('Password', validators=[Length(min=6)])
class EditUserForm(FlaskForm):
""" Form for editing a user """
username = StringField('Username', validators=[
DataRequired(), Length(min=3, max=20)])
email = StringField('Email', validators=[DataRequired(), Email()])
first_name = StringField(
'First Name', validators=[Length(max=255)])
last_name = StringField('Last Name', validators=[Length(max=255)])
password = PasswordField(
'Enter your password to confirm', validators=[Length(min=6)])
class EditProfilePicForm(FlaskForm):
""" Form for updating profile image """
profile_pic = FileField('Upload profile Image', validators=[
FileAllowed(['jpg', 'png', 'jpeg'], 'Images only!'), FileRequired("Please select a photo from your files")])