def roughness():
    if session.get("AUTHENTICATED"):
        if session["AUTHENTICATED"] is True:
            roads = session["road_list"]
            road_id = 752
            road_name = "01S-0667"
            start_m = 1200
            end_m = 1700
            road = {"name": road_name, "start_m": start_m, "end_m": end_m}
            site = session["site"]
            path = session["basePath"]
            headers = session["headers"]

            data = json.dumps(getRoughnessData(road_id, start_m, end_m, site, path, headers))
            return render_template(
                "pages/roughness.html",
                title="Roughness Charts",
                header="Roughness",
                nav="Roughness",
                roads=roads,
                data=data,
                road=road,
            )
    else:
        return redirect(url_for("ramm_login"))
Exemple #2
0
def roughness():
    token = session.get('token')
    print token['token']
    if request.method == 'POST':
        form = request.form
        session['token']['road_id'] = form['road_id']
        session['token']['start_m'] = form['start_m']
        session['token']['end_m'] = form['end_m']

    road_id = session['token']['road_id'] if session['token']['road_id'] else 0
    start_m = session['token']['start_m'] if session['token']['start_m'] else 0
    end_m = session['token']['end_m'] if session['token']['end_m'] else 0

    roads = session['token']['roadnames'] if session['token']['roadnames'] else 0
    road_name = '(not selected)'

    #find the correct road name
    for r in roads:
        if str(r[0]) == str(road_id):
            road_name = r[1]
            break

    section = {'road_name': str(road_name), 'road_id': road_id, 'start_m': start_m, 'end_m': end_m}
    data = getRoughnessData(token=token['token'], road_id=str(road_id), start_m=str(start_m), end_m=str(end_m))

    #add all errors from the data retrieval from to the flashed messages queue
    if len(data['errors']) > 0:
        for e in data['errors']:
            flash(e)

    return render_template(
        'pages/roughness.html',
        title='Roughness Charts',
        header='Roughness',
        nav='Rutting',
        roads=roads,
        data=json.dumps(data['data']),
        section=section
        )