from yasi_applets.summary import bp
from flask import Flask, request, session, redirect, \
     url_for, render_template, flash, Blueprint
from flask import current_app

@bp.route('/summary',methods=['GET', 'POST', 'PUT'])
def summary_index():
    """
    The page you'd get if you access the root of
    this app in a browser.
    """
    build_menu()
    menu = current_app.config['CONFIG']['settings']['menu_order'].split(" ")
    previous_step_url = menu[menu.index("summary")-1]
    next_step_url = "install"

    config = current_app.config['CONFIG']
    print (current_app.config['CONFIG']['Summary'])
    html = (str(current_app.config['CONFIG']['Summary']['welcome']) + "<br>" + str(current_app.config['CONFIG']['Summary']['software']))
    summary = config['Summary']

    print("Config is: ")
    print(config)

    return render_template('summary.html',
        menu=current_app.config['CONFIG']['settings']['menu'],
	menu_order=current_app.config['CONFIG']['settings']['menu_order'].split(),
	previous_step=previous_step_url,
	next_step=next_step_url,
	config=config,
	html=html,
	summary=summary)


def build_menu():
    """
    Define menu items and paths.
    """
    # proper one once translations are done:
    #current_app.config['CONFIG']['settings']['menu']['welcome'] = (build_stringlist()['menu_item'], "/welcome", 10)
    current_app.config['CONFIG']['settings']['menu']['summary'] = ("Summary", "/summary", 60)


build_menu()

