Commit d06ff332 authored by Aurel's avatar Aurel

system preferences must not be taken into account if they are not enabled


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@21446 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent bc620b66
......@@ -230,7 +230,8 @@ class PreferenceTool(BaseTool):
prefs.append(pref)
prefs.sort(lambda b, a: cmp(a.getPriority(), b.getPriority()))
# add system preferences after user preferences
sys_prefs = [x.getObject() for x in self.searchFolder(portal_type='System Preference', **kw)]
sys_prefs = [x.getObject() for x in self.searchFolder(portal_type='System Preference', **kw) \
if x.getObject().getProperty('preference_state', 'broken') in ('enabled', 'global')]
sys_prefs.sort(lambda b, a: cmp(a.getPriority(), b.getPriority()))
return sys_prefs + prefs
......
......@@ -433,9 +433,18 @@ class TestPreferences(ERP5TypeTestCase):
preference_tool = self.portal.portal_preferences
site_pref = preference_tool.newContent(
portal_type='System Preference',
preferred_accounting_transaction_simulation_state_list="this_is_default",
priority=Priority.SITE)
# check not taken into account if not enabled
self.assertEquals(None,
preference_tool.getPreferredAccountingTransactionSimulationStateList())
# enable it and check preference is returned
self.portal.portal_workflow.doActionFor(site_pref, 'enable_action')
self.assertEquals(site_pref.getPreferenceState(), 'global')
get_transaction().commit()
self.tic()
self.assertEquals(['this_is_default'],
preference_tool.getPreferredAccountingTransactionSimulationStateList())
# Members can't add new system preferences
uf = self.getPortal().acl_users
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment