Beispiel #1
0
def test_settings(db_session):
    from kotti.resources import get_root
    from kotti_settings.util import get_settings
    assert get_settings() == {}

    data = {'foo': u'bar', 'bar': u'foo'}
    root = get_root()
    root.annotations['kotti_settings'] = data
    assert get_settings() == {'foo': u'bar', 'bar': u'foo'}
Beispiel #2
0
 def before(self, form):
     settings = get_settings()
     for key in form.cstruct:
         if key in settings:
             # Convert boolean to 'true' or 'false' to meet the
             # requirements of deform's checkbox widget.
             if isinstance(settings[key], bool):
                 value = settings[key] and 'true' or 'false'
             else:
                 value = settings[key]
             form.cstruct[key] = value
     form.formid = self.form_id