Beispiel #1
0
def route_page(route_id):
    try:
        route_id = ObjectId(route_id)
    except :
        flash('invalid route_id')
        return redirect(url_for('home.home'))
    
    route = RouteHelper.get(route_id)

    route.author = UserHelper.get(route.author)
    route.formatted_time = get_formatted_time(route.create_ts)
    route.stat = RouteHelper.get_route_stat(route.id)
    route.cleaned_content = route.content.read().decode('utf-8')  # TODO: use bleach to sanitise html
    route.my_rate = RouteHelper.get_user_rate(route.id)
    attachs = RouteHelper.get_attachs(route.id)
    joined = route.id in current_user.entered_routes
    finished = RouteHelper.is_route_finished(route.id)

    if not route.finished:
        return redirect(url_for('route.add_attach_page', route_id=route.id))

    return render_template('route-detail.html', route=route, attachs=attachs, joined=joined, finished=finished)