Commit 6ec89c42 authored by Jérome Perrin's avatar Jérome Perrin

extend createPreferenceForUser API to enable the preference directly.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@35612 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 245ce4d7
......@@ -295,8 +295,9 @@ class PreferenceTool(BaseTool):
security.declareProtected(Permissions.ManagePortal,
'createPreferenceForUser')
def createPreferenceForUser(self, username):
"""Creates a preference for a given user.
def createPreferenceForUser(self, username, enable=True):
"""Creates a preference for a given user, and optionnally enable the
preference.
"""
security_manager = getSecurityManager()
try:
......@@ -305,7 +306,10 @@ class PreferenceTool(BaseTool):
if user is None:
raise ValueError("User %r not found" % (username, ))
newSecurityManager(None, user.__of__(user_folder))
return self.newContent(portal_type='Preference')
preference = self.newContent(portal_type='Preference')
if enable:
preference.enable()
return preference
finally:
setSecurityManager(security_manager)
......
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