-
Notifications
You must be signed in to change notification settings - Fork 0
/
forms.py
59 lines (42 loc) · 2.85 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
51
52
53
54
55
56
57
58
59
from flask_wtf import FlaskForm
from models import User, Car
from wtforms import StringField, PasswordField, IntegerField, validators, BooleanField, SelectField,DateTimeField
from wtforms.validators import DataRequired
from wtforms_alchemy import Unique, ModelForm
class RegistrationForm(ModelForm, FlaskForm):
username = StringField('Username', validators=[DataRequired(),
Unique(User.username,
message="User with username exists")])
email = StringField('Email', validators=[DataRequired(),
validators.Email(message="Must be a valid email address"),
Unique(User.email, message="User with email exists")])
mobile = IntegerField('Mobile', validators=[DataRequired()])
password = PasswordField('Password', validators=[DataRequired(),
validators.EqualTo('confirm_password',
message='Passwords must match')])
confirm_password = PasswordField('Repeat Password')
class ProfileForm(ModelForm, FlaskForm):
username = StringField('Username', validators=[DataRequired(),
Unique(User.username,
message="User with username exists")])
email = StringField('Email', validators=[DataRequired(),
validators.Email(message="Must be a valid email address"),
Unique(User.email, message="User with email exists")])
mobile = IntegerField('Mobile', validators=[DataRequired()])
first_name = StringField('First Name',validators=[DataRequired()])
last_name = StringField('First Name',validators=[DataRequired()])
email_notifications = BooleanField('Email Notifications')
text_notifications = BooleanField('Text Notifications')
class BookingForm(ModelForm, FlaskForm):
cars = Car.query.all()
car_list = []
#car.id, car.make + car.model
for car in cars:
car_make_model = car.make + " " + car.model
car_list.append((car.id,car_make_model ))
car_id = SelectField('Car',choices=car_list,coerce=int, validators=[DataRequired()])
start_date_time = DateTimeField('Start Date/Time', id="start_date_time",format='%Y-%m-%d %H:%M:%S',validators=[DataRequired()])
end_date_time = DateTimeField('End Date/Time',id="end_date_time", format='%Y-%m-%d %H:%M:%S',validators=[DataRequired()])
class LoginForm(ModelForm, FlaskForm):
username = StringField('Username', validators=[DataRequired()])
password = PasswordField('Password', validators=[DataRequired()])