1234567891011121314151617181920212223242526272829303132 |
- from flask_wtf import FlaskForm
- from wtforms import SubmitField, StringField, SelectField, TimeField, DateField
- from wtforms.validators import DataRequired, URL
- class CafeForm(FlaskForm):
- cafe = StringField('Cafe name', validators=[DataRequired()])
- location = StringField('Location URL', validators=[DataRequired(), URL()])
- open = TimeField('Open time', validators=[DataRequired()])
- close = TimeField('Closing time', validators=[DataRequired()])
- coffee_rating = SelectField(
- 'Coffee rating', validators=[DataRequired()],
- choices=['☕️', '☕️☕️', '☕️☕️☕️', '☕️☕️☕️☕️', '☕️☕️☕️☕️☕️']
- )
- wifi_rating = SelectField(
- 'Wifi rating', validators=[DataRequired()],
- choices=['✘', '💪', '💪💪', '💪💪💪', '💪💪💪💪', '💪💪💪💪💪']
- )
- power_rating = SelectField(
- 'Power rating', validators=[DataRequired()],
- choices=['✘', '🔌', '🔌🔌', '🔌🔌🔌', '🔌🔌🔌🔌', '🔌🔌🔌🔌🔌']
- )
- submit = SubmitField('Submit')
- # Exercise:
- # add: Location URL, open time, closing time, coffee rating, wifi rating, power outlet rating fields
- # make coffee/wifi/power a select element with choice of 0 to 5.
- #e.g. You could use emojis ☕️/💪/✘/🔌
- # make all fields required except submit
- # use a validator to check that the URL field has a URL entered.
- # ---------------------------------------------------------------------------
|