-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathforms.py
339 lines (312 loc) · 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
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
from flask_wtf import FlaskForm
from wtforms import StringField, PasswordField, SelectField, IntegerField, BooleanField, HiddenField, DateField, URLField
from wtforms.validators import DataRequired, InputRequired, Email, Length, EqualTo, Optional
class RegistrationForm(FlaskForm):
"""Form to register a user."""
username = StringField('Username', validators=[
InputRequired(),
Length(max=40, message="40 characters or less.")
])
email = StringField('Email', validators=[
InputRequired(),
Email(message="Must be a valid email address."),
Length(max=100, message="Must 100 characters or less.")
])
password = PasswordField('Password', validators=[
InputRequired(),
Length(min=8, message="Must be at least 8 characters.")
])
password_confirm = PasswordField("Confirm Password", validators=[
InputRequired(),
EqualTo(fieldname="password", message="Passwords do not match.")
])
class LoginForm(FlaskForm):
"""Form to login user."""
username = StringField("Username", validators=[InputRequired()])
password = PasswordField("Password", validators=[InputRequired()])
class ChangePasswordForm(FlaskForm):
"""Form to allow user to change their password."""
old_password = PasswordField("Old Password", validators=[InputRequired()])
new_password = PasswordField("New Password", validators=[
InputRequired(),
Length(min=8, message="Must be at least 8 characters.")
])
password_confirm = PasswordField("Confirm New Password", validators=[
InputRequired(),
EqualTo(fieldname="new_password", message="Passwords do not match.")
])
class UserEditForm(FlaskForm):
"Form to edit a user and add additional info"
first_name = StringField('Username', validators=[
Length(max=40, message="Must be less than 40 characters.")
])
last_name = StringField('Username', validators=[
Length(max=40, message="Must be less than 40 characters.")
])
country = SelectField('Country', choices=[
'Afghanistan', 'Albania', 'Algeria', 'Andorra', 'Angola', 'Antigua and Barbuda',
'Argentina', 'Armenia', 'Australia', 'Austria', 'Azerbaijan', 'Bahamas', 'Bahrain',
'Bangladesh', 'Barbados', 'Belarus', 'Belgium', 'Belize', 'Benin', 'Bhutan',
'Bolivia', 'Bosnia and Herzegovina', 'Botswana', 'Brazil', 'Brunei', 'Bulgaria',
'Burkina Faso', 'Burundi', 'Côte d''Ivoire', 'Cabo Verde', 'Cambodia', 'Cameroon',
'Canada', 'Central African Republic', 'Chad', 'Chile', 'China', 'Colombia',
'Comoros', 'Republic of Condo', 'Costa Rica', 'Croatia', 'Cuba', 'Cyprus',
'Czechia (Czech Republic)', 'Democratic Republic of the Congo', 'Denmark', 'Djibouti',
'Dominica', 'Dominican Republic', 'Ecuador', 'Egypt', 'El Salvador', 'Equatorial Guinea',
'Eritrea', 'Estonia', 'Eswatini', 'Ethiopia', 'Fiji', 'Finland', 'France', 'Gabon',
'Gambia', 'Georgia', 'Germany', 'Ghana', 'Greece', 'Grenada', 'Guatemala', 'Guinea',
'Guinea-Bissau', 'Guyana', 'Haiti', 'Holy See', 'Honduras', 'Hungary', 'Iceland', 'India',
'Indonesia', 'Iran', 'Iraq', 'Ireland', 'Israel', 'Italy', 'Jamaica', 'Japan', 'Jordan',
'Kazakhstan', 'Kenya', 'Kiribati', 'Kuwait', 'Kyrgyzstan', 'Laos', 'Latvia', 'Lebanon',
'Lesotho', 'Liberia', 'Libya', 'Liechtenstein', 'Lithuania', 'Luxembourg', 'Madagascar',
'Malawi', 'Malaysia', 'Maldives', 'Mali', 'Malta', 'Marshall Islands', 'Mauritania',
'Mauritius', 'Mexico', 'Micronesia', 'Moldova', 'Monaco', 'Mongolia', 'Montenegro',
'Morocco', 'Mozambique', 'Myanmar', 'Namibia', 'Nauru', 'Nepal', 'Netherlands',
'New Zealand', 'Nicaragua', 'Niger', 'Nigeria', 'North Korea', 'North Macedonia', 'Norway',
'Oman', 'Pakistan', 'Palau', 'Palestine State', 'Panama', 'Papua New Guinea', 'Paraguay',
'Peru', 'Philippines', 'Poland', 'Portugal', 'Qatar', 'Romania', 'Russia', 'Rwanda',
'Saint Kitts and Nevis', 'Saint Lucia', 'Saint Vincent and the Grenadines', 'Samoa',
'San Marino', 'Sao Tome and Principe', 'Saudi Arabia', 'Senegal', 'Serbia', 'Seychelles',
'Sierra Leone', 'Singapore', 'Slovakia', 'Slovenia', 'Solomon Islands', 'Somalia',
'South Africa', 'South Korea', 'South Sudan', 'Spain', 'Sri Lanka', 'Sudan', 'Suriname',
'Sweden', 'Switzerland', 'Syria', 'Tajikistan', 'Tanzania', 'Thailand', 'Timor-Leste',
'Togo', 'Tonga', 'Trinidad and Tobago', 'Tunisia', 'Turkey', 'Turkmenistan', 'Tuvalu',
'Uganda', 'Ukraine', 'United Arab Emirates', 'United Kingdom', 'U.S.A',
'Uruguay', 'Uzbekistan', 'Vanuatu', 'Venezuela', 'Vietnam', 'Yemen', 'Zambia', 'Zimbabwe'
])
state = SelectField('State', choices=[
'Alabama', 'Alaska', 'American Samoa', 'Arizona', 'Arkansas', 'California', 'Colorado',
'Connecticut', 'Delaware', 'District of Columbia', 'Florida', 'Georgia', 'Guam', 'Hawaii',
'Idaho', 'Illinois', 'Indiana', 'Iowa', 'Kansas', 'Kentucky', 'Louisiana', 'Maine',
'Maryland', 'Massachusetts', 'Michigan', 'Minnesota', 'Minor Outlying Islands',
'Mississippi', 'Missouri', 'Montana', 'Nebraska', 'Nevada', 'New Hampshire', 'New Jersey',
'New Mexico', 'New York', 'North Carolina', 'North Dakota', 'Northern Mariana Islands',
'Ohio', 'Oklahoma', 'Oregon', 'Pennsylvania', 'Puerto Rico', 'Rhode Island',
'South Carolina', 'South Dakota', 'Tennessee', 'Texas', 'U.S. Virgin Islands', 'Utah',
'Vermont', 'Virginia', 'Washington', 'West Virginia', 'Wisconsin', 'Wyoming'
])
linkedin_url = StringField('Linkedin URL', validators=[
Length(max=150, message="Must be less than 150 characters.")
])
class ApiJobSearchForm(FlaskForm):
"""Form to fetch api job list data."""
keyword = StringField("What", validators=[InputRequired()], render_kw={"placeholder": "job title, keywords or O*NET-SOC code"})
location = StringField("Where", render_kw={"placeholder": "zip code or city, state"})
radius = IntegerField("Radius", validators=[Optional()], render_kw={"placeholder": "miles"})
days = IntegerField("Days Old", validators=[Optional()])
companyName = StringField("Company Name")
remote = BooleanField("Remote Only")
# If remote only is selected, add "remote" to user's keyword input
startRecord = HiddenField("Start", default=0)
# class MiniCosJobSearchForm(FlaskForm):
# """Mini form to fetch COS job list data."""
# keyword = StringField("What", validators=[InputRequired()], render_kw={"placeholder": "job title, O*NET code, or keywords"})
# location = StringField("Where", render_kw={"placeholder": "zip code or city, state"})
class ManualJobAddForm(FlaskForm):
"""Form to manually add a job."""
title = StringField("Job Title", validators=[InputRequired()])
company = StringField("Company", validators=[InputRequired()])
location = StringField("Location", validators=[
Length(max=100, message="Must be less than 100 characters."),
InputRequired()
])
date_posted = DateField("Date Posted", validators=[InputRequired()])
application_link = URLField("Link")
job_description = StringField("Description")
job_type = SelectField("Job Type", choices=[
('-', ''),
('f', 'Full-time'),
('p', 'Part-time'),
('c', 'Contract'),
('i', 'Internship'),
('v', 'Volunteer')
], validators=[Optional()])
# '-' changed to Null in JS file
experience_level = SelectField("Experience Level", choices=[
('-', ''),
('i', 'Internship'),
('e', 'Entry level'),
('a', 'Associate'),
('m', 'Mid-Senior level'),
('d', 'Director'),
('x', 'Executive'),
], validators=[Optional()])
# '-' changed to Null in JS file
salary_min = StringField("Salary range")
salary_max = StringField()
# ******************* write custom validator that requires both or none of below ************************
# https://stackoverflow.com/questions/42614091/wtforms-create-form-with-both-or-no-fields-that-validates-but-not-just-one-fie
company_size = SelectField("Company Size", choices=[
('-', ''),
(1, '1-10 employees'),
(2, '11-50 employees'),
(3, '51-200 employees'),
(4, '201-500 employees'),
(5, '501-1,000 employees'),
(6, '1,001-5,000 employees'),
(7, '5,001-10,000 employees'),
(8, '10,001+ employees')
], validators=[Optional()])
# '-' changed to Null in JS file
federal_contractor = SelectField("Federal contractor", choices=[
('-', ''),
('True', 'Yes'),
('False', 'No')
], validators=[Optional()])
# coerced to True, False, or None in models.SavedJob.save_job
user_notes = StringField("User Notes")
class SavedJobRegularEditForm(FlaskForm):
"""Form to edit a saved job"""
title = StringField("Job Title")
company = StringField("Company")
location = StringField("Location", validators=[
Length(max=100, message="Must be less than 100 characters.")
])
date_posted = DateField("Date Posted", validators=[Optional()])
application_link = URLField("Link")
job_description = StringField("Description")
job_type = SelectField("Job Type", choices=[
('-', ''),
('f', 'Full-time'),
('p', 'Part-time'),
('c', 'Contract'),
('i', 'Internship'),
('v', 'Volunteer')
], validators=[Optional()])
# '-' changed to Null in JS file
experience_level = SelectField("Experience Level", choices=[
('-', ''),
('i', 'Internship'),
('e', 'Entry level'),
('a', 'Associate'),
('m', 'Mid-Senior level'),
('d', 'Director'),
('x', 'Executive'),
], validators=[Optional()])
# '-' changed to Null in JS file
salary_min = StringField("Salary range")
salary_max = StringField()
# ******************* write custom validator that requires both or none of below ************************
# https://stackoverflow.com/questions/42614091/wtforms-create-form-with-both-or-no-fields-that-validates-but-not-just-one-fie
company_size = SelectField("Company Size", choices=[
('-', ''),
(1, '1-10 employees'),
(2, '11-50 employees'),
(3, '51-200 employees'),
(4, '201-500 employees'),
(5, '501-1,000 employees'),
(6, '1,001-5,000 employees'),
(7, '5,001-10,000 employees'),
(8, '10,001+ employees')
], validators=[Optional()])
# '-' changed to Null in JS file
federal_contractor = SelectField("Federal contractor", choices=[
('-', ''),
('True', 'Yes'),
('False', 'No')
])
# coerced to True, False, or None in models.SavedJob.save_job
user_notes = StringField("User Notes")
class SavedJobCosEditForm(FlaskForm):
"""Form to edit a saved job"""
job_type = SelectField("Job Type", choices=[
('-', ''),
('f', 'Full-time'),
('p', 'Part-time'),
('c', 'Contract'),
('i', 'Internship'),
('v', 'Volunteer')
], validators=[Optional()])
# '-' changed to Null in JS file
experience_level = SelectField("Experience Level", choices=[
('-', ''),
('i', 'Internship'),
('e', 'Entry level'),
('a', 'Associate'),
('m', 'Mid-Senior level'),
('d', 'Director'),
('x', 'Executive'),
], validators=[Optional()])
# '-' changed to Null in JS file
salary_min = StringField("Salary range")
salary_max = StringField()
# ******************* write custom validator that requires both or none of below ************************
# https://stackoverflow.com/questions/42614091/wtforms-create-form-with-both-or-no-fields-that-validates-but-not-just-one-fie
company_size = SelectField("Company Size", choices=[
('-', ''),
(1, '1-10 employees'),
(2, '11-50 employees'),
(3, '51-200 employees'),
(4, '201-500 employees'),
(5, '501-1,000 employees'),
(6, '1,001-5,000 employees'),
(7, '5,001-10,000 employees'),
(8, '10,001+ employees')
], validators=[Optional()])
# '-' changed to Null in JS file
user_notes = StringField("User Notes")
class NewJobHuntForm(FlaskForm):
"""Form to create a new Job Hunt from dialog. Form is not displayed."""
name = StringField(validators=[InputRequired()])
job_title_desired = StringField(validators=[InputRequired()])
o_net_code = StringField()
location = StringField()
radius = IntegerField(validators=[Optional()])
non_us = BooleanField()
remote = BooleanField()
app_goal_time_frame = StringField()
app_goal_number = IntegerField()
hired_by_goal_date = DateField()
description = StringField()
# https://stackoverflow.com/questions/33429510/wtforms-selectfield-not-properly-coercing-for-booleans
class JobAppEditForm(FlaskForm):
"""Form to edit a job app."""
date_applied = DateField("Date Applied")
current_status = SelectField("Current Status", choices=[
(2, 'Initial Screening'),
(3, 'Passed IS - No Interview Yet'),
(4, 'Interviewed - First Round'),
(5, 'Interviewed - Multiple Rounds'),
(6, 'Interviewed - Final Round'),
(7, 'Job Offer'),
(8, 'Hired'),
(0, 'Closed - Ghosted'),
(1, 'Closed - Rejection Notice')
])
user_notes = StringField("Application Notes")
class JobHuntEditForm(FlaskForm):
"""Form to edit a job hunt."""
name = StringField("Name", validators=[
Length(max=50, message="Must be 50 characters or less.")])
status = SelectField("Status", choices=[
('a', 'Actively Applying'),
('p', 'On Pause'),
('h', 'Closed, Hired'),
('c', 'Closed, Abandoned')])
date_begun = DateField("Date Begun")
job_title_desired = StringField("Desired Job Title")
o_net_code = StringField('O*NET-SOC Code', validators=[
Length(max=10, message='Must be 10 charaters long (Example: "15-1252.00").')])
non_us = SelectField('Country', choices=[
('False', 'United States'),
('True', 'Outside the U.S.')
])
location = StringField("Location", validators=[
Length(max=100, message="Must be 100 characters or less.")])
radius = IntegerField("Location Radius")
remote = BooleanField("Remote")
hired_by_goal_date = DateField("Hired By")
app_goal_number = IntegerField("I hope to complete")
app_goal_time_frame = SelectField("applications", choices=[
('d', 'Daily'),
('w', 'Weekly'),
('m', 'Monthly')])
description = StringField()
# class JobAppCreateForm(FlaskForm):
# """Form to create a new job app from dialog. Form is not displayed."""
# date_applied = DateField()
# # In popup-ja.html I add a custom select field here from which the value is transferred to the job_hunt_id field
# id = IntegerField()
# # saved job id
# user_id = IntegerField()
# job_hunt_id = IntegerField()