Пример #1
0
def admin_settings():
    available_themes = [
        x.identifier for x in get_themes_list() if x.identifier != 'admin']
    settings = Setting.all()
    for setting in settings:
        if setting.name == 'blog-theme':
            setting.allowed = json.dumps(available_themes)
    return render_admin('settings.html', settings=settings)
Пример #2
0
def get_settings():
    '''
    Gets all the settings for the app.
    '''
    settings = {}
    all_settings = Setting.all()
    for setting in all_settings:
        settings[setting.name.strip()] = setting.val

    return settings
Пример #3
0
def upgrade_settings():
    settings = Setting.all()
    print(settings)

    bootstrap_theme = filter_results(settings, 'name', 'bootstrap-theme')[0]
    if json.loads(bootstrap_theme.allowed) != THEMES:
        print("Upgrading allowed Bootstrap themes.")
        bootstrap_theme.allowed = json.dumps(THEMES)
        if bootstrap_theme.value not in THEMES:
            print("Old theme not allowed. Setting random one.")
            bootstrap_theme.value = THEMES[0]
        bootstrap_theme.insert()

    syntax_theme = filter_results(settings, 'name', 'syntax-highlighting-theme')[0]
    if json.loads(syntax_theme.allowed) != SYNTAX_THEMES:
        print("Upgrading allowed syntax highlighting themes.")
        syntax_theme.allowed = json.dumps(SYNTAX_THEMES)
        if syntax_theme.value not in SYNTAX_THEMES:
            print("old syntax highlighting theme not allowed. Setting random one.")
            syntax_theme.value = SYNTAX_THEMES[0]
        syntax_theme.insert()

    safe_commit()