當前位置: 首頁>>代碼示例>>Python>>正文


Python Setting.get_settings方法代碼示例

本文整理匯總了Python中flaskbb.management.models.Setting.get_settings方法的典型用法代碼示例。如果您正苦於以下問題:Python Setting.get_settings方法的具體用法?Python Setting.get_settings怎麽用?Python Setting.get_settings使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在flaskbb.management.models.Setting的用法示例。


在下文中一共展示了Setting.get_settings方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _determine_active_settings

# 需要導入模塊: from flaskbb.management.models import Setting [as 別名]
# 或者: from flaskbb.management.models.Setting import get_settings [as 別名]
    def _determine_active_settings(self, slug, plugin):
        """Determines which settings are active.
        Returns a tuple in following order:
            ``form``, ``old_settings``, ``plugin_obj``, ``active_nav``
        """
        # Any ideas how to do this better?
        slug = slug if slug else 'general'
        active_nav = {}  # used to build the navigation
        plugin_obj = None
        if plugin is not None:
            plugin_obj = PluginRegistry.query.filter_by(name=plugin
                                                        ).first_or_404()
            active_nav.update(
                {
                    'key': plugin_obj.name,
                    'title': plugin_obj.name.title()
                }
            )
            form = plugin_obj.get_settings_form()
            old_settings = plugin_obj.settings

        elif slug is not None:
            group_obj = SettingsGroup.query.filter_by(key=slug).first_or_404()
            active_nav.update({'key': group_obj.key, 'title': group_obj.name})
            form = Setting.get_form(group_obj)()
            old_settings = Setting.get_settings(group_obj)

        return form, old_settings, plugin_obj, active_nav
開發者ID:eirnym,項目名稱:flaskbb,代碼行數:30,代碼來源:views.py

示例2: settings

# 需要導入模塊: from flaskbb.management.models import Setting [as 別名]
# 或者: from flaskbb.management.models.Setting import get_settings [as 別名]
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.get_settings(active_group)
    new_settings = {}

    form = SettingsForm()

    if form.validate_on_submit():
        for key, values in iteritems(old_settings):
            try:
                # check if the value has changed
                if values['value'] == form[key].data:
                    continue
                else:
                    new_settings[key] = form[key].data
            except KeyError:
                pass
        Setting.update(settings=new_settings, app=current_app)
        flash(_("Settings saved."), "success")
    else:
        for key, values in iteritems(old_settings):
            try:
                form[key].data = values['value']
            except (KeyError, ValueError):
                pass

    return render_template("management/settings.html", form=form,
                           all_groups=all_groups, active_group=active_group)
開發者ID:0xsKu,項目名稱:flaskbb,代碼行數:38,代碼來源:views.py


注:本文中的flaskbb.management.models.Setting.get_settings方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。