From 415b16b2f4bd17298e0d00935a9830ded3477bfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com> Date: Wed, 16 Aug 2006 07:51:12 +0000 Subject: [PATCH] use a standard ERP5Type Property to manage preferences' priority git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@9221 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5/PropertySheet/Preference.py | 8 +++++++- product/ERP5Form/Document/Preference.py | 15 --------------- product/ERP5Form/tests/testPreferences.py | 10 ++++++---- 3 files changed, 13 insertions(+), 20 deletions(-) diff --git a/product/ERP5/PropertySheet/Preference.py b/product/ERP5/PropertySheet/Preference.py index e394d7f05e..1ea80e410d 100644 --- a/product/ERP5/PropertySheet/Preference.py +++ b/product/ERP5/PropertySheet/Preference.py @@ -26,12 +26,18 @@ # ############################################################################## -class Preference : +class Preference: """ User Preference PropertySheet """ _properties = ( + { 'id' : 'priority', + 'description' : 'Priority of the preference.', + 'type' : 'int', + 'default' : 3, # ( Priority.USER ) + 'mode' : 'w', + 'write_permission': 'View management screens', }, { 'id' : 'preferred_section_category', 'description' : 'The section category for documents; '\ 'usually something like group/nexedi.', diff --git a/product/ERP5Form/Document/Preference.py b/product/ERP5Form/Document/Preference.py index 2978aabdc0..d5b7fcebd8 100644 --- a/product/ERP5Form/Document/Preference.py +++ b/product/ERP5Form/Document/Preference.py @@ -62,18 +62,3 @@ class Preference( Folder ): security = ClassSecurityInfo() security.declareObjectProtected(Permissions.AccessContentsInformation) - def __init__(self, id) : - Folder.__init__(self, id) - self.priority = Priority.USER - - security.declareProtected(Permissions.ViewManagementScreens, 'setPriority') - def setPriority(self, priority) : - """ Sets the priority of the preference""" - self.priority = priority - self.reindexObjectSecurity() - - security.declareProtected(Permissions.View, 'getPriority') - def getPriority(self) : - """ Returns the priority of the preference """ - return self.priority - diff --git a/product/ERP5Form/tests/testPreferences.py b/product/ERP5Form/tests/testPreferences.py index 850689571b..d7171ea38f 100644 --- a/product/ERP5Form/tests/testPreferences.py +++ b/product/ERP5Form/tests/testPreferences.py @@ -44,7 +44,7 @@ from Products.ERP5Form.Document.Preference import Priority class TestPreferences(ERP5TypeTestCase): - quiet = 0 + quiet = 1 run_all_tests = 1 def getTitle(self): @@ -60,12 +60,14 @@ class TestPreferences(ERP5TypeTestCase): newSecurityManager(None, user) self.createPreferences() + def beforeTearDown(self): + portal_preferences = self.getPreferenceTool() + portal_preferences.manage_delObjects(list(portal_preferences.objectIds())) + get_transaction().commit() + def createPreferences(self) : """ create some preferences objects """ portal_preferences = self.getPreferenceTool() - if getattr(portal_preferences, 'person1', None) is not None : - portal_preferences.manage_delObjects([ - 'person1', 'person2', 'group', 'site']) ## create initial preferences person1 = portal_preferences.newContent( id='person1', portal_type='Preference') -- 2.30.9