-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathqueryDropDowns.py
128 lines (121 loc) · 5.39 KB
/
queryDropDowns.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
# this is a work in progress that will grab unique column values to allow for dropdown menus instead of text boxes in
# the search form
def query_drop_downs():
drop_downs = {}
cylinders = [('4 cylinders',), (None,), ('10 cylinders',), ('8 cylinders',), ('6 cylinders',), ('5 cylinders',),
('3 cylinders',), ('other',), ('12 cylinders',)]
fuel = [(None,), ('other',), ('hybrid',), ('gas',), ('diesel',), ('electric',)]
title_status = [(None,), ('salvage',), ('parts only',), ('missing',), ('lien',), ('clean',), ('rebuilt',)]
drive = [(None,), ('rwd',), ('fwd',), ('4wd',)]
vehicle_type = [(None,), ('wagon',), ('sedan',), ('SUV',), ('bus',), ('truck',), ('mini-van',), ('convertible',),
('pickup',), ('hatchback',), ('other',), ('offroad',), ('coupe',), ('van',)]
paint_color = [('purple',), ('orange',), ('green',), ('blue',), ('brown',), ('grey',), ('yellow',), ('black',),
('white',), ('red',), (None,), ('silver',), ('custom',)]
manufacturer = [(None,), ('chevrolet',), ('mazda',), ('acura',), ('audi',), ('nissan',), ('mini',),
('mercedes-benz',), ('chrysler',), ('ram',), ('kia',), ('pontiac',), ('bmw',), ('hennessey',),
('infiniti',), ('volkswagen',), ('morgan',), ('ford',), ('harley-davidson',), ('jaguar',),
('fiat',), ('hyundai',), ('volvo',), ('gmc',), ('rover',), ('alfa-romeo',), ('honda',),
('mercury',), ('aston-martin',), ('buick',), ('lexus',), ('tesla',), ('toyota',), ('saturn',),
('land rover',), ('mitsubishi',), ('cadillac',), ('subaru',), ('lincoln',), ('jeep',), ('porsche',),
('datsun',), ('ferrari',), ('dodge',)]
condition = [('excellent',), ('new',), ('good',), ('fair',), (None,), ('salvage',), ('like new',)]
size = [('sub-compact',), (None,), ('mid-size',), ('compact',), ('full-size',)]
transmission = [(None,), ('other',), ('manual',), ('automatic',)]
transmissions = []
for item in transmission:
item = item[0]
if item is not None:
transmissions.append((item, item.title()))
transmissions.append(("", ""))
transmissions.sort()
drop_downs["transmission"] = transmissions
sizes = []
for item in size:
item = item[0]
if item is not None:
sizes.append((item, item.title()))
sizes.append(("", ""))
sizes.sort()
drop_downs["size"] = sizes
cyls = []
for item in cylinders:
item = item[0]
if item is not None:
cyls.append((item, item.title()))
cyls.append(("", ""))
cyls.sort()
drop_downs["cylinders"] = cyls
fuels = []
for item in fuel:
item = item[0]
if item is not None:
fuels.append((item, item.title()))
fuels.append(("", ""))
fuels.sort()
drop_downs["fuel"] = fuels
title_status_list = []
for item in title_status:
item = item[0]
if item is not None:
title_status_list.append((item, item.title()))
title_status_list.append(("", ""))
title_status_list.sort()
drop_downs["title_status"] = title_status_list
drives = []
for item in drive:
item = item[0]
if item is not None:
drives.append((item, item.title()))
drives.append(("", ""))
drives.sort()
drop_downs["drive"] = drives
vehicle_types = []
for item in vehicle_type:
item = item[0]
if item is not None:
vehicle_types.append((item, item.title()))
vehicle_types.append(("", ""))
vehicle_types.sort()
drop_downs["vehicle_type"] = vehicle_types
paint_colors = []
for item in paint_color:
item = item[0]
if item is not None:
paint_colors.append((item, item.title()))
paint_colors.append(("", ""))
paint_colors.sort()
drop_downs["paint_color"] = paint_colors
manufacturers = []
for item in manufacturer:
item = item[0]
if item is not None:
manufacturers.append((item, item.title()))
manufacturers.append(("", ""))
manufacturers.sort()
drop_downs["manufacturer"] = manufacturers
conditions = []
for item in condition:
item = item[0]
if item is not None:
conditions.append((item, item.title()))
conditions.append(("", ""))
conditions.sort()
drop_downs["condition"] = conditions
states = ["AL", "AK", "AZ", "AR", "CA", "CO", "CT", "DC", "DE", "FL", "GA",
"HI", "ID", "IL", "IN", "IA", "KS", "KY", "LA", "ME", "MD",
"MA", "MI", "MN", "MS", "MO", "MT", "NE", "NV", "NH", "NJ",
"NM", "NY", "NC", "ND", "OH", "OK", "OR", "PA", "RI", "SC",
"SD", "TN", "TX", "UT", "VT", "VA", "WA", "WV", "WI", "WY"]
state_tuples = [("", "")]
for item in states:
state_tuples.append((item, item))
drop_downs["states"] = state_tuples
sort_by_list = ["Price low to high", "Price high to low", "Odometer low to high", "Odometer high to low",
"Year low to high", "Year high to low"]
sort_by_tuples = [("", "")]
for item in sort_by_list:
sort_by_tuples.append((item, item))
drop_downs["sort_by"] = sort_by_tuples
drop_downs["numerical_fields"] = [(item, item) for item in ["price", "odometer", "year"]]
drop_downs["numerical_fields_backwards"] = [(item, item) for item in ["year", "odometer", "price"]]
return drop_downs