Commit 430397aa authored by Jean-Paul Smets's avatar Jean-Paul Smets

Added support for keep_default in all category list setters

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@10005 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 3a76f8db
...@@ -1290,7 +1290,7 @@ class Base( CopyContainer, PortalContent, ActiveObject, Historical, ERP5Property ...@@ -1290,7 +1290,7 @@ class Base( CopyContainer, PortalContent, ActiveObject, Historical, ERP5Property
# Private accessors for the implementation of relations based on # Private accessors for the implementation of relations based on
# categories # categories
security.declareProtected( Permissions.ModifyPortalContent, '_setValue' ) security.declareProtected( Permissions.ModifyPortalContent, '_setValue' )
def _setValue(self, id, target, spec=(), filter=None, portal_type=()): def _setValue(self, id, target, spec=(), filter=None, portal_type=(), keep_default=1):
if target is None : if target is None :
path = target path = target
elif isinstance(target, str): elif isinstance(target, str):
...@@ -1310,7 +1310,7 @@ class Base( CopyContainer, PortalContent, ActiveObject, Historical, ERP5Property ...@@ -1310,7 +1310,7 @@ class Base( CopyContainer, PortalContent, ActiveObject, Historical, ERP5Property
# We have been provided an object # We have been provided an object
# Find the object # Find the object
path = target.getRelativeUrl() path = target.getRelativeUrl()
self._setCategoryMembership(id, path, spec=spec, filter=filter, portal_type=portal_type) self._setCategoryMembership(id, path, spec=spec, filter=filter, portal_type=portal_type, keep_default=keep_default)
security.declareProtected( Permissions.ModifyPortalContent, '_setDefaultValue' ) security.declareProtected( Permissions.ModifyPortalContent, '_setDefaultValue' )
_setDefaultValue = _setValue _setDefaultValue = _setValue
...@@ -1319,8 +1319,8 @@ class Base( CopyContainer, PortalContent, ActiveObject, Historical, ERP5Property ...@@ -1319,8 +1319,8 @@ class Base( CopyContainer, PortalContent, ActiveObject, Historical, ERP5Property
_setValueList = _setValue _setValueList = _setValue
security.declareProtected( Permissions.ModifyPortalContent, 'setValue' ) security.declareProtected( Permissions.ModifyPortalContent, 'setValue' )
def setValue(self, id, target, spec=(), filter=None, portal_type=()): def setValue(self, id, target, spec=(), filter=None, portal_type=(), keep_default=1):
self._setValue(id, target, spec=spec, filter=filter, portal_type=portal_type) self._setValue(id, target, spec=spec, filter=filter, portal_type=portal_type, keep_default=keep_default)
self.reindexObject() self.reindexObject()
security.declareProtected( Permissions.ModifyPortalContent, 'setDefaultValue' ) security.declareProtected( Permissions.ModifyPortalContent, 'setDefaultValue' )
...@@ -1440,17 +1440,17 @@ class Base( CopyContainer, PortalContent, ActiveObject, Historical, ERP5Property ...@@ -1440,17 +1440,17 @@ class Base( CopyContainer, PortalContent, ActiveObject, Historical, ERP5Property
return uid_list return uid_list
security.declareProtected( Permissions.ModifyPortalContent, '_setValueUids' ) security.declareProtected( Permissions.ModifyPortalContent, '_setValueUids' )
def _setValueUids(self, id, uids, spec=(), filter=None, portal_type=()): def _setValueUids(self, id, uids, spec=(), filter=None, portal_type=(), keep_default=1):
# We must do an ordered list so we can not use the previous method # We must do an ordered list so we can not use the previous method
# self._setValue(id, self.portal_catalog.getObjectList(uids), spec=spec) # self._setValue(id, self.portal_catalog.getObjectList(uids), spec=spec)
references = [] references = []
for uid in uids: for uid in uids:
references.append(self.portal_catalog.getObject(uid)) references.append(self.portal_catalog.getObject(uid))
self._setValue(id, references, spec=spec, filter=filter, portal_type=portal_type) self._setValue(id, references, spec=spec, filter=filter, portal_type=portal_type, keep_default=keep_value)
security.declareProtected( Permissions.ModifyPortalContent, 'setValueUids' ) security.declareProtected( Permissions.ModifyPortalContent, 'setValueUids' )
def setValueUids(self, id, uids, spec=(), filter=None, portal_type=()): def setValueUids(self, id, uids, spec=(), filter=None, portal_type=(), keep_default=1):
self._setValueUids(id, uids, spec=spec, filter=filter, portal_type=portal_type) self._setValueUids(id, uids, spec=spec, filter=filter, portal_type=portal_type, keep_default=keep_default)
self.reindexObject() self.reindexObject()
security.declareProtected( Permissions.ModifyPortalContent, '_addValue' ) security.declareProtected( Permissions.ModifyPortalContent, '_addValue' )
...@@ -1476,16 +1476,16 @@ class Base( CopyContainer, PortalContent, ActiveObject, Historical, ERP5Property ...@@ -1476,16 +1476,16 @@ class Base( CopyContainer, PortalContent, ActiveObject, Historical, ERP5Property
security.declareProtected( Permissions.ModifyPortalContent, '_setCategoryMembership' ) security.declareProtected( Permissions.ModifyPortalContent, '_setCategoryMembership' )
def _setCategoryMembership(self, category, node_list, spec=(), def _setCategoryMembership(self, category, node_list, spec=(),
filter=None, portal_type=(), base=0): filter=None, portal_type=(), base=0, keep_default=1):
self._getCategoryTool().setCategoryMembership(self, category, node_list, self._getCategoryTool().setCategoryMembership(self, category, node_list,
spec=spec, filter=filter, portal_type=portal_type, base=base) spec=spec, filter=filter, portal_type=portal_type, base=base, keep_default=keep_default)
#self.activate().edit() # Do nothing except call workflow method #self.activate().edit() # Do nothing except call workflow method
# XXX This is a problem - it is used to circumvent a lack of edit # XXX This is a problem - it is used to circumvent a lack of edit
security.declareProtected( Permissions.ModifyPortalContent, 'setCategoryMembership' ) security.declareProtected( Permissions.ModifyPortalContent, 'setCategoryMembership' )
def setCategoryMembership(self, category, node_list, spec=(), portal_type=(), base=0): def setCategoryMembership(self, category, node_list, spec=(), portal_type=(), base=0, keep_default=1):
self._setCategoryMembership(category, self._setCategoryMembership(category,
node_list, spec=spec, filter=filter, portal_type=portal_type, base=base) node_list, spec=spec, filter=filter, portal_type=portal_type, base=base, keep_default=keep_default)
self.reindexObject() self.reindexObject()
security.declareProtected( Permissions.ModifyPortalContent, '_setDefaultCategoryMembership' ) security.declareProtected( Permissions.ModifyPortalContent, '_setDefaultCategoryMembership' )
......
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