-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathforms.py
25 lines (23 loc) · 1.59 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
from flask_wtf import FlaskForm
from wtforms import StringField, SubmitField, SelectField, DateField
from wtforms.validators import DataRequired, Length
from datetime import datetime, timedelta
today = datetime.today().date()
default_depart = today + timedelta(days=1)
default_return = today + timedelta(days=3)
class FlightSearchForm(FlaskForm):
departure_city = StringField("Departure City", render_kw={"placeholder": "From where?"},
validators=[DataRequired(), Length(min=3, max=30)])
destination_city = StringField("Destination City", render_kw={"placeholder": "To where?"},
validators=[DataRequired(), Length(min=3, max=30)])
adults = SelectField("Adults", choices=[(1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6), (7, 7), (8, 8), (9, 9)],
validators=[DataRequired()])
children = SelectField("Children", choices=[(0, 0), (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6), (7, 7), (8, 8), (9, 9)],
validators=[DataRequired()])
infants = SelectField("Infants", choices=[(0, 0), (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6), (7, 7), (8, 8), (9, 9)],
validators=[DataRequired()])
date_from = DateField("Depart", validators=[DataRequired()], default=default_depart)
date_to = DateField("Return", validators=[DataRequired()], default=default_return)
currency = SelectField("Currency", choices=[("CAD", "CAD"), ("USD", "USD"), ("EUR", "EUR")],
validators=[DataRequired()])
submit = SubmitField("Search Flights")