-
Notifications
You must be signed in to change notification settings - Fork 2
/
forms.py
89 lines (67 loc) · 2.15 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
from flask_wtf import Form
from wtforms import TextField, PasswordField
from wtforms.validators import DataRequired, Length
from wtforms import SelectField
# Registration WTF form when logged in
# as Admin or Manager
class RegisterForm(Form):
role = SelectField(
'Account Type', choices=[
('admin', 'Admin'),
('manager', 'Manager'),
('user', 'User')])
userid = TextField(
'Username', validators=[DataRequired(), Length(min=2, max=25)]
)
name = TextField(
'Name', validators=[DataRequired(), Length(min=6, max=25)]
)
email = TextField(
'Email', validators=[DataRequired(), Length(min=6, max=40)]
)
password = PasswordField(
'Password', validators=[DataRequired(), Length(min=2, max=40)]
)
# Registration WTF form without logging.
class RegistrationForm(Form):
role = SelectField(
'Account Type', choices=[
('user', 'User')])
userid = TextField(
'Username', validators=[DataRequired(), Length(min=2, max=25)]
)
name = TextField(
'Name', validators=[DataRequired(), Length(min=6, max=25)]
)
email = TextField(
'Email', validators=[DataRequired(), Length(min=6, max=40)]
)
password = PasswordField(
'Password', validators=[DataRequired(), Length(min=2, max=40)]
)
# Login WTF LoginForm
class LoginForm(Form):
name = TextField('Username', [DataRequired()])
password = PasswordField('Password', [DataRequired()])
# Post Message WTF form
class PostMessage(Form):
message = TextField('Message', [DataRequired()])
# Update WTF form
class UpdateForm(Form):
role = SelectField(
'Account Type', choices=[
('admin', 'Admin'),
('manager', 'Manager'),
('user', 'User')])
userid = TextField(
'New Username', validators=[DataRequired(), Length(min=2, max=25)]
)
name = TextField(
'New Name', validators=[Length(min=6, max=25)]
)
email = TextField(
'New Email', validators=[Length(min=6, max=40)]
)
password = PasswordField(
'New Password', validators=[Length(min=2, max=40)]
)