Skip to content

Commit

Permalink
fixing profiles with no reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnEaganFS committed Nov 28, 2021
1 parent 5594067 commit 19cde89
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions application.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,16 +191,19 @@ def reviews(usr):
if (g.user['name'] == usr):
isUser = True

avgStars = round(sum([review['reviewScore'] for review in profile_user['reviews']]) / len(profile_user['reviews']))
if not(len(profile_user['reviews'])) == 0:
avgStars = round(sum([review['reviewScore'] for review in profile_user['reviews']]) / len(profile_user['reviews']))

#print(profile_user['reviews'])
review_data = [users.find_one({'name': review['reviewerName']})['profile']['location'] for review in profile_user['reviews']]
#print(review_data)
for i, loc in enumerate(review_data):
profile_user['reviews'][i]['location'] = loc
#print(profile_user['reviews'])
#print(profile_user['reviews'])
review_data = [users.find_one({'name': review['reviewerName']})['profile']['location'] for review in profile_user['reviews']]
#print(review_data)
for i, loc in enumerate(review_data):
profile_user['reviews'][i]['location'] = loc
#print(profile_user['reviews'])

return render_template("reviews.html", profileResult = profile_user, isUser = isUser, avgStars=avgStars)
return render_template("reviews.html", profileResult = profile_user, isUser = isUser, avgStars=avgStars)
else:
return render_template("reviews.html", profileResult = profile_user, isUser = isUser, avgStars=0)

@application.route("/addreview/<usr>", methods = ["POST", "GET"])
def addReview(usr):
Expand Down

0 comments on commit 19cde89

Please sign in to comment.