from applets.hardware import bp from flask import Flask, request, session, redirect, \ url_for, render_template, flash, Blueprint from flask import current_app @bp.route('/hardware') def webui_hardware(): """ Hardware screen for the webui. """ menu = current_app.config['CONFIG']['settings']['menu_order'].split(" ") next_step_url = menu[menu.index("hardware")+1] if menu[menu.index("hardware")] == 1: previous_step_url = False else: previous_step_url = menu[menu.index("hardware")-1] sources_button = '  ' blends_button = '  ' bottom_menu = sources_button + blends_button build_summary() return render_template('hardware.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, bottom_menu = bottom_menu, popcon=current_app.config['CONFIG']['recipe']['popcon']['enable_popcon']) @bp.route('/hardware/settings', methods=['GET', 'POST']) def hardware_settings(): """ Receive settings for the hardware applet. """ if request.method == 'POST': popcon = "popcon" in request.form current_app.config['CONFIG']['recipe']['popcon']['enable_popcon'] = popcon print(current_app.config['CONFIG']['recipe']['popcon']['enable_popcon']) build_summary() return ('', 204) 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']['hardware'] = ("Hardware", "/hardware", 40) def build_summary(): """ Write up a summary of what this module will do. """ current_app.config['CONFIG']['Summary']['hardware'] = {} current_app.config['CONFIG']['Summary']['hardware']['heading'] = "Hardware" current_app.config['CONFIG']['Summary']['hardware']['bleh'] = current_app.config['CONFIG']['recipe']['popcon']['enable_popcon'] current_app.config['CONFIG']['Summary']['hardware']['text'] = "Participate in Popularity Contest: " + str(current_app.config['CONFIG']['recipe']['popcon']['enable_popcon']) + "
No desktop environment selected." return("ok?") build_menu()