def set_mode(mode): if (mode < 1 or mode > 3): return 404 settings = get_settings_json() settings['mode'] = mode update_settings_json(settings) return redirect('/settings')
def resolve_stage_request(stage): settings = get_settings_json() if (stage == 4): return render_template('settings-experimental-stage.html', stage=settings['stage_four']) elif (1 <= stage and stage <= 3): stage_natural_name, stage_natural_number = natural_stage_names(stage) return render_template('settings-intro-stage.html', stage_num=stage, stage_name=stage_natural_name, stage=settings[stage_natural_number]) else: return 404
def scan_tasks(): settings = get_settings_json() old_task_list = [(task['number'], task['selected']) for task in settings['stage_four']['tasks']] old_tasks = dict(old_task_list) old_pilot_task_list = [(task['number'], task['selected']) for task in settings['pilot_mode']['tasks']] old_pilot_tasks = dict(old_pilot_task_list) tasks = [] pilot_tasks = [] for entry in os.scandir(f'{base_dir}/tasks'): if (entry.path.endswith(".json") and entry.is_file()): task = get_json(entry.path) tasks.append({ "number": task['task_number'], "name": task['task_name'], "selected": (old_tasks[task['task_number']] if task['task_number'] in old_tasks else False) }) pilot_tasks.append({ "number": task['task_number'], "name": task['task_name'], "selected": (old_pilot_tasks[task['task_number']] if task['task_number'] in old_pilot_tasks else False) }) settings['stage_four']['tasks'] = tasks settings['pilot_mode']['tasks'] = pilot_tasks update_settings_json(settings)
def settings_modes(): settings = get_settings_json() return render_template('settings-modes.html', mode=settings['mode'])
def pilot_route(): settings = get_settings_json() return render_template('index.html', welcome_text=settings['general']['welcome_text'], \ main_script='../static/pilot.js')
def api_pilot_settings(): settings = get_settings_json() return settings['pilot_mode']
def api_experimental_settings(): settings = get_settings_json() return settings['stage_four']
def api_settings(): return get_settings_json()
def settings_pilot(): settings = get_settings_json() return render_template('settings-pilot.html', stage=settings['pilot_mode'])
def update_task_lists(task_settings): settings = get_settings_json() update_single_task_list(settings, 'task_four', task_settings) update_single_task_list(settings, 'pilot_mode', task_settings) update_settings_json(settings)
def settings_tasks(): settings = get_settings_json() return render_template('settings-tasks.html', tasks=settings['stage_four']['tasks'])
def submit_settings(new_settings, fieldname): settings = get_settings_json() settings[fieldname] = new_settings update_settings_json(settings)
def settings_general(): settings = get_settings_json() return render_template('settings-general.html', general=settings['general'])