def review_run(): """Allows the user to view a previous run.""" if flask_session.get("email") == None: flash("You must sign in to view that page.") return redirect("/") current_run_id = request.args.get("run_id") current_run = model.get_run_by_id(current_run_id) current_ratings = model.get_ratings_for_run(current_run_id) html_parse = HTMLParser.HTMLParser() instagram_html = current_ratings[9] instagram_html = instagram_html.text_ans instagram_html = html_parse.unescape(instagram_html) colors = {} for i in range(4): if current_ratings[i].numeric_ans < 2: colors[i] = "#E03A29" elif current_ratings[i].numeric_ans < 4: colors[i] = "#E4EB11" else: colors[i] = "#21BF23" color_zero = colors[0] color_one = colors[1] color_two = colors[2] color_three = colors[3] score = model.get_run_score(current_run_id) if current_run.route == 0 or current_run.route == None: current_route = None else: current_route = model.get_route_by_id(current_run.route) #creates an edit url. url = "/edit_run.html?run_id=" + str(current_run_id) # The page variable determines which tabs are active. page = "run" location_image = model.location_badges_dictionary[current_ratings[5].select_ans] terrain_image = model.terrain_badges_dictionary[current_ratings[6].select_ans] route_image = model.route_badges_dictionary[current_ratings[7].select_ans] return render_template("view_run.html", run=current_run, ratings = current_ratings, terrain_dictionary = model.terrain_dictionary, route_dictionary = model.route_dictionary, score = score, color_zero = color_zero, color_one = color_one, color_two = color_two, color_three = color_three, instagram_html = instagram_html, edit_url=url, page = page, current_route = current_route, location_image = location_image, route_image = route_image, terrain_image = terrain_image)
def view_user_route(): """Lets the user view details about a single route.""" if flask_session.get("email") == None: flash("You must sign in to view that page.") return redirect("/") user = model.get_user_by_email(flask_session["email"]) # The page variable determines which tabs are active. page = "route" current_route_id = request.args.get("route_id") current_route = model.get_route_by_id(current_route_id) return render_template("view_route.html", page = page, route = current_route)