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

            data = json.dumps(getSCRIMData(road_id, start_m, end_m, site, path, headers))
            return render_template(
                "pages/scrim.html", title="SCRIM Charts", header="SCRIM", nav="SCRIM", roads=roads, data=data, road=road
            )
    else:
        return redirect(url_for("ramm_login"))
Exemplo n.º 2
0
def scrim():
    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 = getSCRIMData(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/scrim.html',
        title='SCRIM Charts',
        header='SCRIM',
        nav='SCRIM',
        roads=roads,
        data=json.dumps(data['data']),
        section=section
        )