コード例 #1
0
ファイル: __init__.py プロジェクト: vireshbackup/indico
 def user_settings(cls):
     """:class:`UserSettingsProxy` for the plugin's user-specific settings"""
     if cls.name is None:
         raise RuntimeError('Plugin has not been loaded yet')
     instance = cls.instance
     with instance.plugin_context():  # in case the default settings come from a property
         return UserSettingsProxy('plugin_{}'.format(cls.name), instance.default_user_settings,
                                  cls.strict_settings, converters=cls.user_settings_converters)
コード例 #2
0
ファイル: settings.py プロジェクト: mkopcic/indico
#
# Indico is free software; you can redistribute it and/or
# modify it under the terms of the MIT License; see the
# LICENSE file for more details.

from indico.core.settings.converters import EnumConverter, ModelListConverter
from indico.modules.users import UserSettingsProxy
from indico.util.i18n import _
from indico.util.struct.enum import RichIntEnum


class RoomEmailMode(RichIntEnum):
    __titles__ = (_('None'), _('Rooms I own'), _('Rooms I manage'),
                  _('Rooms I own or manage'))
    none = 0
    owned = 1
    managed = 2
    all = 3


rb_user_settings = UserSettingsProxy('roombooking', {
    'email_mode': RoomEmailMode.all,
    'email_blacklist': [],
},
                                     converters={
                                         'email_mode':
                                         EnumConverter(RoomEmailMode),
                                         'email_blacklist':
                                         ModelListConverter('Room'),
                                     })