Skip to content

Commit 3e46750

Browse files
authored
Merge pull request #40 from vs2961/users
Add no cars page for profile
2 parents f455300 + a530a8e commit 3e46750

File tree

22 files changed

+329
-132
lines changed

22 files changed

+329
-132
lines changed

Scraping/kbb_parser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ def getCars(html, site, out):
5252
continue
5353

5454
if chosen_horsepower == "0":
55-
bruh = chosen_car.replace(" ", "+") + "+HP"
56-
a = requests.get(f"https://www.google.com/search?q={bruh}/").text
55+
hp1 = chosen_car.replace(" ", "+") + "+HP"
56+
a = requests.get(f"https://www.google.com/search?q={hp1}/").text
5757
soup3 = BeautifulSoup(a, features="html.parser")
5858
try:
5959
chosen_horsepower = soup3.findAll("div", {"class":"BNeawe iBp4i AP7Wnd"})[0].text[0:3]

website/app/production.db

0 Bytes
Binary file not shown.

website/app/views.py

Lines changed: 47 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,37 +29,59 @@ def serve():
2929
def dump_sorted():
3030
req_data = request.get_json()
3131
cars = Car.query
32+
sort = False
3233
big_cars = []
3334
if req_data["Price"]:
35+
sort = True
3436
for price in req_data["Price"]:
3537
mini_cars = cars.filter(Car.MSRP <= price[1])\
3638
.filter(Car.MSRP >= price[0])
3739
big_cars.append(mini_cars)
40+
3841
if req_data["Type"]:
42+
sort = True
3943
if len(big_cars) == 0:
4044
for car_type in req_data["Type"]:
4145
mini_cars = cars.filter_by(type=car_type)
4246
big_cars.append(mini_cars)
4347
else:
48+
poses = []
4449
for i in range(len(big_cars)):
4550
for car_type in req_data["Type"]:
46-
big_cars[i] = big_cars[i].filter_by(type=car_type)
51+
pos = big_cars[i].filter_by(type=car_type)
52+
poses.append(pos)
53+
big_cars = poses.copy()
4754

4855
if req_data["Seats"]:
56+
sort = True
4957
if len(big_cars) == 0:
5058
for seat in req_data["Seats"]:
5159
mini_cars = cars.filter(Car.seats.between(
5260
seat[0], seat[1]))
61+
big_cars.append(mini_cars)
5362
else:
63+
poses = []
5464
for i in range(len(big_cars)):
5565
for seat in req_data["Seats"]:
56-
big_cars[i] = big_cars[i].filter(Car.seats.between(seat[0], seat[1]))
57-
final_list = []
58-
for car in big_cars:
59-
for k in car.all():
60-
final_list.append(k)
61-
cars = sorted([car.serialize() for car in final_list],
62-
key=lambda x: x[req_data["sort_by"]], reverse=True)
66+
pos = big_cars[i].filter(Car.seats.between(seat[0], seat[1]))
67+
poses.append(pos)
68+
big_cars = poses.copy()
69+
if sort:
70+
final_list = []
71+
for car in big_cars:
72+
for k in car.all():
73+
if k not in final_list:
74+
final_list.append(k)
75+
if req_data["sort_by"] == "MSRP":
76+
cars = sorted([car.serialize() for car in final_list],
77+
key=lambda x: x[req_data["sort_by"]])
78+
else:
79+
cars = sorted([car.serialize() for car in final_list],
80+
key=lambda x: x[req_data["sort_by"]], reverse=True)
81+
else:
82+
cars = sorted([car.serialize() for car in cars.all()],
83+
key=lambda x: x[req_data["sort_by"]], reverse=True)
84+
6385
return jsonify(split(cars, 3))
6486

6587

@@ -68,14 +90,16 @@ def dump_rating():
6890
req_data = request.get_json()
6991
cars = Car.query
7092
big_cars = []
93+
sort = False
7194
if req_data["Price"]:
95+
sort = True
7296
for price in req_data["Price"]:
7397
mini_cars = cars.filter(Car.MSRP <= price[1])\
7498
.filter(Car.MSRP >= price[0])
7599
big_cars.append(mini_cars)
76-
print("AFTER PRICE: ")
77-
print(big_cars)
100+
78101
if req_data["Type"]:
102+
sort = True
79103
if len(big_cars) == 0:
80104
for car_type in req_data["Type"]:
81105
mini_cars = cars.filter_by(type=car_type)
@@ -89,25 +113,30 @@ def dump_rating():
89113
big_cars = poses.copy()
90114

91115
if req_data["Seats"]:
116+
sort = True
92117
if len(big_cars) == 0:
93118
for seat in req_data["Seats"]:
94119
mini_cars = cars.filter(Car.seats.between(
95120
seat[0], seat[1]))
121+
big_cars.append(mini_cars)
96122
else:
97123
poses = []
98124
for i in range(len(big_cars)):
99125
for seat in req_data["Seats"]:
100126
pos = big_cars[i].filter(Car.seats.between(seat[0], seat[1]))
101127
poses.append(pos)
102128
big_cars = poses.copy()
103-
print(len(big_cars))
104-
final_list = []
105-
for car in big_cars:
106-
for k in car.all():
107-
if k not in final_list:
108-
final_list.append(k)
109-
cars = sorted([car.serialize() for car in final_list],
110-
key=lambda x: x[req_data["sort_by"]], reverse=True)
129+
if sort:
130+
final_list = []
131+
for car in big_cars:
132+
for k in car.all():
133+
if k not in final_list:
134+
final_list.append(k)
135+
cars = sorted([car.serialize() for car in final_list],
136+
key=lambda x: x[req_data["sort_by"]], reverse=True)
137+
else:
138+
cars = sorted([car.serialize() for car in cars.all()],
139+
key=lambda x: x[req_data["sort_by"]], reverse=True)
111140

112141
return jsonify(cars)
113142

website/client/package-lock.json

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

website/client/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"dependencies": {
66
"@material-ui/core": "^4.9.9",
77
"@material-ui/icons": "^4.9.1",
8+
"@material-ui/lab": "^4.0.0-alpha.55",
89
"@testing-library/jest-dom": "^4.2.4",
910
"@testing-library/react": "^9.5.0",
1011
"@testing-library/user-event": "^7.2.1",

website/client/public/arrowup.png

9.37 KB
Loading

website/client/public/nocars.jpg

50.3 KB
Loading
754 KB
Loading

website/client/src/homepage/About.js

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,7 @@ import "../styles/about.css";
33
import Grid from '@material-ui/core/Grid'
44
import IntroCard from './IntroCard'
55
function About() {
6-
const what = `
7-
Look, we get it. Buying cars is a hassle. Car salesperson aren't good people!
8-
They're going to scam you to buy at whatever price they're coaxing you at!
9-
But today, my fellow car enthusiast, it all changes. With EZCar, you are going to
10-
have a honest experience in finding the car for you. Don't worry! We'll obviously help you in the entire process.
11-
Just create an account and get started!`
6+
const what = "More than 3 in 5 Americans believe that they are exploited when shopping at car dealerships. They seek a \“more transparent pricing process\” as well as more \“flexibility and speed.\” We get it: buying cars is a hassle. That\’s why we created EZCar: your personal car dealer. We start with the specs that matter to you––gas mileage, seating, price––and serve up the best rides. Simple, streamlined, EZ!"
127

138
const how = `Our application is for the modern world. No one likes to get bogged down with a ton of text.
149
Images and icons are the new thing! We've made the car search a whole lot friendlier and interactive.
@@ -25,23 +20,20 @@ function About() {
2520
<div >
2621
<h1>Welcome!</h1>
2722
<Grid container spacing={3}>
28-
<Grid item xs={4}>
29-
<IntroCard title={"What is this?"} text={what}/>
23+
<Grid item xs={6}>
24+
<IntroCard title={"Our Story"} text={what}/>
3025
</Grid>
31-
<Grid item xs={4}>
32-
<IntroCard title={"Get Started"} text={get_started}/>
33-
</Grid>
34-
<Grid item xs={4}>
35-
<IntroCard title={"Background Info"} text={who}/>
26+
<Grid item xs={6}>
27+
<IntroCard title={"Tutorials"} hasImage = {true} imageSource = {"tutorial1.gif"}/>
28+
3629
</Grid>
37-
<Grid item xs={4}>
38-
<IntroCard title={"How?"} text={how}/>
30+
<Grid item xs={6}>
31+
<IntroCard title={"Code Used"} text={get_started}/>
3932
</Grid>
40-
<Grid item xs={4}>
41-
<iframe width="100%" height="100%"
42-
src="https://www.youtube.com/embed/tgbNymZ7vqY">
43-
</iframe>
33+
<Grid item xs={6}>
34+
<IntroCard title={"Team"} text={who}/>
4435
</Grid>
36+
4537
</Grid>
4638
</div>
4739
)

website/client/src/homepage/InfoDrawer.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ function MaterialInfoDrawer() {
4141
setState({ ...state, [anchor]: open });
4242
}
4343

44-
const routes = ["/", "/profile", "/cars", "/about"]
45-
const icons = [<BugReportIcon/>, <AccountCircleIcon/>, <DriveEtaIcon/>, <InfoIcon/>]
44+
const routes = ["/", "/profile", "/about"]
45+
const icons = [<DriveEtaIcon/>, <AccountCircleIcon/>, <InfoIcon/>]
4646
const [cookies, setCookie, removeCookie] = useCookies(['username', 'id']);
4747

4848
const topics = (anchor) => (
@@ -51,7 +51,7 @@ function MaterialInfoDrawer() {
5151
onKeyDown={toggleDrawer(anchor, false)}>
5252
{/* Just maps out the topics, making listitems for each one */}
5353
<List>
54-
{['Introduction', 'Profile', 'Cars', 'About'].map((text, index) => (
54+
{['Introduction', 'Profile', 'About'].map((text, index) => (
5555
<>
5656
<ListItem button key={index}>
5757
{text == 'Profile' && typeof cookies.id == "undefined" ? null : <NavLink key={index} to={routes[index]} >

0 commit comments

Comments
 (0)