Skip to content

Commit 1923275

Browse files
committed
readjusted Line length
1 parent c612177 commit 1923275

File tree

4 files changed

+23
-14
lines changed

4 files changed

+23
-14
lines changed

server/djangoapp/models.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,10 @@ class CarModel(models.Model):
5353
]
5454
type = models.CharField(max_length=15, choices=CAR_TYPES, default="SUV")
5555
year = models.IntegerField(
56-
default=2023, validators=[MaxValueValidator(2023), MinValueValidator(2015)]
57-
)
56+
default=2023,
57+
validators=[
58+
MaxValueValidator(2023),
59+
MinValueValidator(2015)])
5860

5961
def __str__(self):
6062
return f"{self.car_make.name} - {self.name}"

server/djangoapp/populate.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ def initiate():
1313
car_make_instances = []
1414
for data in car_make_data:
1515
car_make_instances.append(
16-
CarMake.objects.create(name=data["name"], description=data["description"])
17-
)
16+
CarMake.objects.create(
17+
name=data["name"],
18+
description=data["description"]))
1819

1920
# Create CarModel instances with the corresponding CarMake instances
2021
car_model_data = [
@@ -54,9 +55,12 @@ def initiate():
5455
"year": 2023,
5556
"car_make": car_make_instances[1],
5657
},
57-
{"name": "A4", "type": "SUV", "year": 2023, "car_make": car_make_instances[2]},
58-
{"name": "A5", "type": "SUV", "year": 2023, "car_make": car_make_instances[2]},
59-
{"name": "A6", "type": "SUV", "year": 2023, "car_make": car_make_instances[2]},
58+
{"name": "A4", "type": "SUV", "year": 2023,
59+
"car_make": car_make_instances[2]},
60+
{"name": "A5", "type": "SUV", "year": 2023,
61+
"car_make": car_make_instances[2]},
62+
{"name": "A6", "type": "SUV", "year": 2023,
63+
"car_make": car_make_instances[2]},
6064
{
6165
"name": "Sorrento",
6266
"type": "SUV",

server/djangoapp/restapis.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def get_request(endpoint, **kwargs):
2626
# Call get method of requests library with URL and parameters
2727
response = requests.get(request_url)
2828
return response.json()
29-
except:
29+
except BaseException:
3030
# If any error occurs
3131
print("Network exception occurred")
3232

@@ -54,7 +54,7 @@ def post_review(data_dict):
5454
response = requests.post(request_url, json=data_dict)
5555
print(response.json())
5656
return response.json()
57-
except:
57+
except BaseException:
5858
print("Network exception occurred")
5959

6060

server/djangoapp/views.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,13 @@ def get_cars(request):
7777
car_models = CarModel.objects.select_related("car_make")
7878
cars = []
7979
for car_model in car_models:
80-
cars.append({"CarModel": car_model.name, "CarMake": car_model.car_make.name})
80+
cars.append({"CarModel": car_model.name,
81+
"CarMake": car_model.car_make.name})
8182
return JsonResponse({"CarModels": cars})
8283

8384

84-
# Update the `get_dealerships` render list of dealerships all by default, particular state if state is passed
85+
# Update the `get_dealerships` render list of dealerships all by default,
86+
# particular state if state is passed
8587
def get_dealerships(request, state="All"):
8688
if state == "All":
8789
endpoint = "/fetchDealers"
@@ -115,12 +117,13 @@ def get_dealer_reviews(request, dealer_id):
115117

116118

117119
def add_review(request):
118-
if request.user.is_anonymous == False:
120+
if not request.user.is_anonymous:
119121
data = json.loads(request.body)
120122
try:
121123
response = post_review(data)
122124
return JsonResponse({"status": 200})
123-
except:
124-
return JsonResponse({"status": 401, "message": "Error in posting review"})
125+
except BaseException:
126+
return JsonResponse(
127+
{"status": 401, "message": "Error in posting review"})
125128
else:
126129
return JsonResponse({"status": 403, "message": "Unauthorized"})

0 commit comments

Comments
 (0)