Commit 21089b22 authored by Tristan Cavelier's avatar Tristan Cavelier Committed by Julien Muchembled

Workaround to make _getSortedPreferenceList faster for Manager

Before, the preference state was tested first, which caused useless ZODB loads.
parent 39911db0
......@@ -162,14 +162,13 @@ class PreferenceTool(BaseTool):
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()
if pref is not None and pref.getProperty('preference_state',
'broken') in ('enabled', 'global'):
# XXX quick workaround so that manager only see user preference
# XXX quick workaround so that managers only see user preference
# they actually own.
if user_is_manager and pref.getPriority() == Priority.USER :
if pref.getOwnerTuple()[1] == user.getId():
prefs.append(pref)
else :
if pref is not None and (not user_is_manager or
pref.getPriority() != Priority.USER or
pref.getOwnerTuple()[1] == user.getId()):
if pref.getProperty('preference_state',
'broken') in ('enabled', 'global'):
prefs.append(pref)
prefs.sort(key=lambda x: x.getPriority(), reverse=True)
# add system preferences before user preferences
......
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