-
Notifications
You must be signed in to change notification settings - Fork 0
/
forms.py
167 lines (142 loc) · 4.44 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
from flask_ckeditor import CKEditorField
from flask_wtf import FlaskForm
from flask_wtf.file import FileField, FileRequired, FileAllowed
from wtforms import (
StringField,
PasswordField,
BooleanField,
IntegerField,
TextAreaField,
SubmitField,
MultipleFileField,
)
from wtforms.fields import simple
from wtforms.validators import DataRequired, Length, ValidationError, Email, Optional
from wtforms import validators
from wtforms import widgets
from wtforms import Form
class LoginForm(FlaskForm):
username = StringField(
"Username",
validators=[validators.DataRequired()],
render_kw={"placeholder": "用户名"},
)
password = PasswordField(
"Password",
validators=[DataRequired()],
render_kw={"placeholder": "密码"},
)
remember = BooleanField("Remember me")
submit = SubmitField("登录")
class selectForm(FlaskForm):
goodsid = StringField(
"goodsid",
validators=[DataRequired()],
render_kw={"placeholder": "商品号"},
)
goodsname = StringField(
"goodsname",
validators=[DataRequired()],
render_kw={"placeholder": "商品名"},
)
store = StringField(
"store",
validators=[DataRequired()],
render_kw={"placeholder": "库存数"},
)
password = PasswordField(
"Password",
validators=[DataRequired()],
render_kw={"placeholder": "密码"},
)
remember = BooleanField("Remember me")
submit = SubmitField("查询")
class addgoodsForm(FlaskForm):
goodsid = StringField(
"商品号: ",
validators=[DataRequired()],
render_kw={"placeholder": "请输入商品号"},
)
predict = StringField(
"运行内存大小: ",
validators=[DataRequired()],
render_kw={"placeholder": "请输入运行内存大小:"},
)
goodsname = StringField(
"商品名: ",
validators=[DataRequired()],
render_kw={"placeholder": "商品名"},
)
goodstatus = StringField(
"商品状态: ",
validators=[DataRequired()],
render_kw={"placeholder": "商品状态"},
)
store = StringField(
"库存数: ",
validators=[DataRequired()],
render_kw={"placeholder": "库存数"},
)
submit = SubmitField("确定")
class goodsForm(FlaskForm):
goodsid = StringField(
"商品号: ",
validators=[DataRequired(), Length(3, 12)],
render_kw={"placeholder": "请输入商品号", "class": "test"},
)
goodsname = StringField(
"商品名: ",
validators=[DataRequired()],
render_kw={"placeholder": "商品名"},
)
goodstype = StringField(
"产品型号: ",
validators=[DataRequired()],
render_kw={"placeholder": "请输入型号名"},
)
body1 = TextAreaField('Body', validators=[DataRequired()])
body2 = TextAreaField('Body', validators=[DataRequired()])
body3 = TextAreaField('Body', validators=[DataRequired()])
# body = StringField('Body', validators=[DataRequired()])
goodsprice = StringField(
"价格: ",
validators=[DataRequired()],
render_kw={"placeholder": "请输入价格"},
)
goodscolor = StringField(
"颜色: ",
validators=[DataRequired()],
render_kw={"placeholder": "请输入商品颜色"},
)
goodsremarks = StringField(
"备注: ",
validators=[Optional(strip_whitespace=True)],
render_kw={"placeholder": "请输入商品描述信息:"},
)
store = StringField(
"库存数: ",
validators=[DataRequired(message="库存数不能为空! ")],
render_kw={"placeholder": "库存数"},
)
submit = SubmitField("确定")
class userForm(FlaskForm):
username = StringField(
"用户名: ",
validators=[validators.DataRequired()],
render_kw={"placeholder": "请输入用户名"},
)
password = PasswordField(
"密码: ",
validators=[DataRequired()],
render_kw={"placeholder": "请输入密码"},
)
submit = SubmitField("添加")
class UploadForm(FlaskForm):
photo = FileField(
"上传商品图片",
validators=[FileRequired(), FileAllowed(["jpg", "jpeg", "png", "gif"])],
)
submit = SubmitField()
class MultiUploadForm(FlaskForm):
photo = MultipleFileField("上传商品图片", validators=[DataRequired()])
submit = SubmitField()