-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbookforms.py
18 lines (15 loc) · 996 Bytes
/
bookforms.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# Inheriting from class FlaskForm, we create a child class with the form fields of our choice for the book additions or corrections
from flask_wtf import FlaskForm
from wtforms import SubmitField, StringField, FloatField
from wtforms.validators import DataRequired, NumberRange, InputRequired
class AddForm(FlaskForm):
book_title = StringField('Book Title', validators=[DataRequired()])
book_author=StringField('Author', validators=[DataRequired()])
rating=FloatField('Rating: 0-10', validators=[InputRequired(),NumberRange(min=0, max=10, message='Please enter a number between 0-10')])
submit = SubmitField('Add Book')
class EditForm(FlaskForm):
new_rating=FloatField('New Rating', validators=[InputRequired(),NumberRange(min=0, max=10, message='Please enter a number between 0-10')])
submit = SubmitField('Change Rating')
class SearchForm(FlaskForm):
search_title = StringField('Book Title', validators=[DataRequired()])
submit = SubmitField('Search Book')