Commit 7f50f790 authored by Jérome Perrin's avatar Jérome Perrin

- include the username in the cache key, because user can change in one transaction

- adjust tests after 38131



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@38350 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 6766f5c3
......@@ -227,13 +227,14 @@ class PreferenceTool(BaseTool):
sorted so that the first in the list should be applied first
"""
tv = getTransactionalVariable(self)
tv_key = 'PreferenceTool._getSortedPreferenceList/%s' % sql_catalog_id
user = getToolByName(self, 'portal_membership').getAuthenticatedMember()
tv_key = 'PreferenceTool._getSortedPreferenceList/%s/%s' % (user,
sql_catalog_id)
if tv.get(tv_key, None) is None:
prefs = []
# XXX will also cause problems with Manager (too long)
# XXX For manager, create a manager specific preference
# or better solution
user = getToolByName(self, 'portal_membership').getAuthenticatedMember()
user_is_manager = 'Manager' in user.getRolesInContext(self)
for pref in self.searchFolder(portal_type='Preference', sql_catalog_id=sql_catalog_id):
pref = pref.getObject()
......@@ -254,7 +255,6 @@ class PreferenceTool(BaseTool):
preference_list = sys_prefs + prefs
tv[tv_key] = preference_list
else:
portal = self.getPortalObject()
preference_list = tv[tv_key]
return preference_list
......
......@@ -104,6 +104,8 @@ class TestPreferences(PropertySheetTestCase):
"""
self.failUnless('Preference' in [x.getId() for x in
self.getPortal().portal_preferences.allowedContentTypes()])
self.failUnless('System Preference' in [x.getId() for x in
self.getPortal().portal_preferences.allowedContentTypes()])
def test_EnablePreferences(self):
""" tests preference workflow """
......@@ -119,6 +121,7 @@ class TestPreferences(PropertySheetTestCase):
person1.portal_workflow.doActionFor(
person1, 'enable_action', wf_id='preference_workflow')
transaction.commit()
self.assertEquals(person1.getPreferenceState(), 'enabled')
self.assertEqual( person1, self.getPreferenceTool().getActivePreference())
......@@ -146,6 +149,7 @@ class TestPreferences(PropertySheetTestCase):
portal_workflow.doActionFor(
person2, 'enable_action', wf_id='preference_workflow')
transaction.commit()
self.assertEqual(person2, self.getPreferenceTool().getActivePreference())
self.assertEqual(None,
self.getPreferenceTool().getActiveSystemPreference())
......@@ -214,6 +218,7 @@ class TestPreferences(PropertySheetTestCase):
# disable person -> group is selected
self.getWorkflowTool().doActionFor(person1,
'disable_action', wf_id='preference_workflow')
transaction.commit()
self.assertEquals(list(pref_tool.getPreference(
'preferred_accounting_transaction_simulation_state_list')),
list(group.getPreferredAccountingTransactionSimulationStateList()))
......
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