예제 #1
0
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')
예제 #2
0
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
예제 #3
0
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)
예제 #4
0
def settings_modes():
    settings = get_settings_json()
    return render_template('settings-modes.html', mode=settings['mode'])
예제 #5
0
def pilot_route():
    settings = get_settings_json()
    return render_template('index.html', welcome_text=settings['general']['welcome_text'], \
                                        main_script='../static/pilot.js')
예제 #6
0
def api_pilot_settings():
    settings = get_settings_json()
    return settings['pilot_mode']
예제 #7
0
def api_experimental_settings():
    settings = get_settings_json()
    return settings['stage_four']
예제 #8
0
def api_settings():
    return get_settings_json()
예제 #9
0
def settings_pilot():
    settings = get_settings_json()
    return render_template('settings-pilot.html', stage=settings['pilot_mode'])
예제 #10
0
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)
예제 #11
0
def settings_tasks():
    settings = get_settings_json()
    return render_template('settings-tasks.html',
                           tasks=settings['stage_four']['tasks'])
예제 #12
0
def submit_settings(new_settings, fieldname):
    settings = get_settings_json()
    settings[fieldname] = new_settings
    update_settings_json(settings)
예제 #13
0
def settings_general():
    settings = get_settings_json()
    return render_template('settings-general.html',
                           general=settings['general'])