Beispiel #1
0
def theme():
    provider = Provider()
    users = provider.users()
    filesystem = provider.filesystem()
    user_settings = provider.user_settings()
    settings = provider.settings()

    user = users.get_by_id(current_user.id)
    themes = filesystem.get_files(
        os.path.join(current_app.root_path, 'static', 'css', 'themes'))
    theme = user_settings.get(current_user.id, 'theme',
                              settings.get('theme', 'lumen'))

    return render_template('config/account/theme.html',
                           user=user,
                           themes=themes,
                           selected_theme=theme)
Beispiel #2
0
def theme_save():
    theme = request.form['theme'].strip()

    provider = Provider()
    filesystem = provider.filesystem()
    user_settings = provider.user_settings()

    themes = filesystem.get_files(
        os.path.join(current_app.root_path, 'static', 'css', 'themes'))

    if not (theme + '.css') in themes:
        flash('Invalid theme', 'error')
        return redirect(url_for('config.theme', user_id=current_user.id))

    user_settings.save(current_user.id, 'theme', theme)

    flash(
        'Theme saved. To make sure everything is working, please force-refresh the page (CTRL-F5)',
        'success')
    return redirect(url_for('config.theme', user_id=current_user.id))
Beispiel #3
0
def theme(user_id):
    if current_user.id != user_id:
        flash('Access denied', 'error')
        return redirect(url_for('home.index'))

    provider = Provider()
    users = provider.users()
    filesystem = provider.filesystem()
    user_settings = provider.user_settings()
    settings = provider.settings()

    user = users.get_by_id(current_user.id)
    themes = filesystem.get_files(
        os.path.join(current_app.root_path, 'static', 'css', 'themes'))
    theme = user_settings.get(user_id, 'theme', settings.get('theme', 'lumen'))

    return render_template('account/theme.html',
                           user=user,
                           themes=themes,
                           selected_theme=theme)
Beispiel #4
0
 def user_setting_get(user_id, name, default=None):
     provider = Provider()
     return provider.user_settings().get(user_id, name, default)