-
Notifications
You must be signed in to change notification settings - Fork 0
/
forms.py
50 lines (43 loc) · 2.06 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
from flask_wtf import FlaskForm
from wtforms import StringField, PasswordField, SubmitField, IntegerField
from wtforms.validators import DataRequired, Email, EqualTo, Length, Optional
class AddBook(FlaskForm):
title = StringField('Book Title',
validators=[DataRequired(message="Enter title please!")])
author = StringField('Author',
validators=[DataRequired(message="Enter author please!")])
isbn = StringField('ISBN number')
year = StringField('Publication Year')
rating = StringField('Rating (1-5)')
review = StringField('Review')
submit = SubmitField('Add Book')
class FindBook(FlaskForm):
title = StringField('Book Title', validators=[DataRequired()])
submit = SubmitField('Find Book')
class AddReview(FlaskForm):
rating = IntegerField('Rating')
review = StringField('Review',
validators=[DataRequired('Enter review please!')])
submit = SubmitField('Add review')
class SignupForm(FlaskForm):
username = StringField('Name', validators=[DataRequired()])
email = StringField('Email Address', validators=[DataRequired(),
Length(min=6),
Email(message='Please enter a valid email')])
password = PasswordField('Password',
validators=
[DataRequired(),
Length(min=6,
message='Please select a stronger password.')])
confirm = PasswordField('Confirm your Password',
validators=[DataRequired(),
EqualTo('password',
message='Passwords must match.')])
submit = SubmitField('Register')
class LoginForm(FlaskForm):
username = StringField('Username',
validators=[DataRequired()])
password = PasswordField('Password', validators=[DataRequired()])
submit = SubmitField('Log In')
class GoogleLogin(FlaskForm):
submit = SubmitField('Login using Google!')