Esempio n. 1
0
def themes() :
    """
        List available themes
    """
    current_app.theme_manager.refresh()
    themes = get_themes_list()
    default_theme = current_app.config['DEFAULT_THEME']
    selected = current_app.config.get(u'THEME', default_theme)
    return render_template('admin/themes.html', themes = themes, 
            selected = selected)
Esempio n. 2
0
def settings():
    form = GeneralSettingsForm()

    form.theme.choices = [(theme.identifier, theme.name)
                          for theme in get_themes_list()]

    if form.validate_on_submit():
        current_user.theme = form.theme.data
        current_user.save()

        flash("Your settings have been updated!", "success")
    else:
        form.theme.data = current_user.theme

    return render_template("user/general_settings.html", form=form)
Esempio n. 3
0
def settings():
    form = GeneralSettingsForm()

    form.theme.choices = [(theme.identifier, theme.name)
                          for theme in get_themes_list()]

    if form.validate_on_submit():
        current_user.theme = form.theme.data
        current_user.save()

        flash("Your settings have been updated!", "success")
    else:
        form.theme.data = current_user.theme

    return render_template("user/general_settings.html", form=form)
Esempio n. 4
0
def settings(slug=None):
    slug = slug if slug else "general"

    # get the currently active group
    active_group = SettingsGroup.query.filter_by(key=slug).first_or_404()
    # get all groups - used to build the navigation
    all_groups = SettingsGroup.query.all()

    SettingsForm = Setting.get_form(active_group)

    old_settings = Setting.as_dict(from_group=slug)
    new_settings = {}

    form = SettingsForm()

    if active_group.key == "themes":
        # get the list with all available themes
        form.default_theme.choices = [(theme.identifier, theme.name)
                                      for theme in get_themes_list()]

    if form.validate_on_submit():
        for key, value in old_settings.iteritems():
            try:
                # check if the value has changed
                if value == form.__dict__[key].data:
                    continue
                else:
                    new_settings[key] = form.__dict__[key].data
            except KeyError:
                pass

        Setting.update(settings=new_settings, app=current_app)
    else:
        for key, value in old_settings.iteritems():
            try:
                form.__dict__[key].data = value
            except (KeyError, ValueError):
                pass

    return render_template("admin/settings.html",
                           form=form,
                           all_groups=all_groups,
                           active_group=active_group)
Esempio n. 5
0
    def test_get_helpers(self):
        app = Flask(__name__)
        app.config['THEME_PATHS'] = [join(TESTS, 'morethemes')]
        Themes(app, app_identifier='testing')

        with app.test_request_context('/'):
            cool = app.theme_manager.themes['cool']
            plain = app.theme_manager.themes['plain']
            assert get_theme('cool') is cool
            assert get_theme('plain') is plain
            tl = get_themes_list()
            assert tl[0] is cool
            assert tl[1] is plain
            try:
                get_theme('notthis')
            except KeyError:
                pass
            else:
                raise AssertionError("Getting a nonexistent theme should "
                                     "raise KeyError")
Esempio n. 6
0
    def test_get_helpers(self):
        app = Flask(__name__)
        app.config['THEME_PATHS'] = [join(TESTS, 'morethemes')]
        Themes(app, app_identifier='testing')

        with app.test_request_context('/'):
            cool = app.theme_manager.themes['cool']
            plain = app.theme_manager.themes['plain']
            assert get_theme('cool') is cool
            assert get_theme('plain') is plain
            tl = get_themes_list()
            assert tl[0] is cool
            assert tl[1] is plain
            try:
                get_theme('notthis')
            except KeyError:
                pass
            else:
                raise AssertionError("Getting a nonexistent theme should "
                                     "raise KeyError")
Esempio n. 7
0
def change_other():
    form = ChangeOtherForm()

    form.language.choices = [(locale, name)
                             for locale, name in
                             current_app.config["AVAILABLE_LANGUAGES"].
                             iteritems()]

    form.theme.choices = [(theme.identifier, theme.name)
                          for theme in get_themes_list()]

    if form.validate_on_submit():
        form.populate_obj(current_user)
        current_user.save()
        flash(_("Your settings have been updated."), "success")
        return redirect(url_for("user.change_other"))
    else:
        form.theme.data = current_user.theme
        form.language.data = current_user.language

    return render_template("user/change_other.html", form=form)
Esempio n. 8
0
def available_themes():
    return [(theme.identifier, theme.name) for theme in get_themes_list()]
Esempio n. 9
0
def available_themes():
    return [(theme.identifier, theme.name) for theme in get_themes_list()]
Esempio n. 10
0
 def index(self):
     themes = get_themes_list()
     theme = Setting.query.filter_by(name=u'theme').first().value
     return self.render('admin/theme.html', themes=themes, chosen_theme=theme)
Esempio n. 11
0
def themes():
    themes = get_themes_list()
    return render('themes.html', themes=themes)
Esempio n. 12
0
 def index(self):
     themes = get_themes_list()
     theme = Setting.query.filter_by(name=u'theme').first().value
     return self.render('admin/theme.html',
                        themes=themes,
                        chosen_theme=theme)
Esempio n. 13
0
def themes():
    themes = get_themes_list()
    return render('themes.html', themes=themes)
Esempio n. 14
0
def get_all_themes():
	themes = get_themes_list()
	return themes