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,15 +162,14 @@ class PreferenceTool(BaseTool): ...@@ -162,15 +162,14 @@ class PreferenceTool(BaseTool):
user_is_manager = 'Manager' in user.getRolesInContext(self) user_is_manager = 'Manager' in user.getRolesInContext(self)
for pref in self.searchFolder(portal_type='Preference', sql_catalog_id=sql_catalog_id): for pref in self.searchFolder(portal_type='Preference', sql_catalog_id=sql_catalog_id):
pref = pref.getObject() pref = pref.getObject()
if pref is not None and pref.getProperty('preference_state', # XXX quick workaround so that managers only see user preference
'broken') in ('enabled', 'global'): # they actually own.
# XXX quick workaround so that manager only see user preference if pref is not None and (not user_is_manager or
# they actually own. pref.getPriority() != Priority.USER or
if user_is_manager and pref.getPriority() == Priority.USER : pref.getOwnerTuple()[1] == user.getId()):
if pref.getOwnerTuple()[1] == user.getId(): if pref.getProperty('preference_state',
'broken') in ('enabled', 'global'):
prefs.append(pref) prefs.append(pref)
else :
prefs.append(pref)
prefs.sort(key=lambda x: x.getPriority(), reverse=True) prefs.sort(key=lambda x: x.getPriority(), reverse=True)
# add system preferences before user preferences # add system preferences before user preferences
sys_prefs = [x.getObject() for x in self.searchFolder(portal_type='System Preference', sql_catalog_id=sql_catalog_id) \ sys_prefs = [x.getObject() for x in self.searchFolder(portal_type='System Preference', sql_catalog_id=sql_catalog_id) \
......
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