Commit de58fb34 authored by Rafael Monnerat's avatar Rafael Monnerat

Introduce a simple method to create one enabled System Preference

This method is usefull for external automation done by SlapOS.
parent ef1f3a89
...@@ -240,6 +240,17 @@ class PreferenceTool(BaseTool): ...@@ -240,6 +240,17 @@ class PreferenceTool(BaseTool):
template_list.append(template) template_list.append(template)
return template_list return template_list
security.declareProtected(Permissions.ManagePortal,
'createActiveSystemPreference')
def createActiveSystemPreference(self):
""" Create a System Preference and enable it if there is no other
enabled System Preference in present.
"""
if self.getActiveSystemPreference() is not None:
raise ValueError("Another Active Preference already exists.")
system_preference = self.newContent(portal_type='System Preference')
system_preference.enable()
security.declareProtected(Permissions.ManagePortal, security.declareProtected(Permissions.ManagePortal,
'createPreferenceForUser') 'createPreferenceForUser')
def createPreferenceForUser(self, username, enable=True): def createPreferenceForUser(self, username, enable=True):
......
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