Commit de783d41 authored by Yoshinori Okuji's avatar Yoshinori Okuji

Add getSelectionParams for convenience.

If selection columns are none, set them to the parameter columns
before returning.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@1202 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent cd4f7671
...@@ -92,7 +92,7 @@ class SelectionTool( UniqueObject, SimpleItem ): ...@@ -92,7 +92,7 @@ class SelectionTool( UniqueObject, SimpleItem ):
""" """
if not REQUEST: if not REQUEST:
REQUEST = get_request() REQUEST = get_request()
if not hasattr(self, 'selection_data'): if not hasattr(self, 'selection_data'):
self.selection_data = PersistentMapping() self.selection_data = PersistentMapping()
user_id = self.portal_membership.getAuthenticatedMember().getUserName() user_id = self.portal_membership.getAuthenticatedMember().getUserName()
...@@ -102,7 +102,7 @@ class SelectionTool( UniqueObject, SimpleItem ): ...@@ -102,7 +102,7 @@ class SelectionTool( UniqueObject, SimpleItem ):
return self.selection_data[user_id].get(selection_name, None) return self.selection_data[user_id].get(selection_name, None)
else: else:
return None return None
security.declareProtected(ERP5Permissions.View, 'setSelectionFor') security.declareProtected(ERP5Permissions.View, 'setSelectionFor')
def setSelectionFor(self, selection_name, selection_object, REQUEST=None): def setSelectionFor(self, selection_name, selection_object, REQUEST=None):
""" """
...@@ -145,6 +145,21 @@ class SelectionTool( UniqueObject, SimpleItem ): ...@@ -145,6 +145,21 @@ class SelectionTool( UniqueObject, SimpleItem ):
#except: #except:
# LOG('WARNING ERP5Form SelectionTool',0,'Could not set Selection') # LOG('WARNING ERP5Form SelectionTool',0,'Could not set Selection')
security.declareProtected(ERP5Permissions.View, 'getSelectionParams')
def getSelectionParams(self, selection_name, params=None, REQUEST=None):
"""
Returns the params in the selection
"""
if params is None: params = []
selection = self.getSelectionFor(selection_name, REQUEST=REQUEST)
if selection is not None:
if len(selection.selection_columns) > 0:
return selection.getSelectionParams()
else:
return params
else:
return params
security.declareProtected(ERP5Permissions.View, 'setSelectionParamsFor') security.declareProtected(ERP5Permissions.View, 'setSelectionParamsFor')
def setSelectionParamsFor(self, selection_name, params, REQUEST=None): def setSelectionParamsFor(self, selection_name, params, REQUEST=None):
""" """
...@@ -326,10 +341,9 @@ class SelectionTool( UniqueObject, SimpleItem ): ...@@ -326,10 +341,9 @@ class SelectionTool( UniqueObject, SimpleItem ):
if columns is None: columns = [] if columns is None: columns = []
selection = self.getSelectionFor(selection_name, REQUEST=REQUEST) selection = self.getSelectionFor(selection_name, REQUEST=REQUEST)
if selection is not None: if selection is not None:
if len(selection.selection_columns) > 0: if len(selection.selection_columns) == 0:
return selection.selection_columns self.setSelectionColumns(selection_name, columns, REQUEST=REQUEST)
else: return selection.selection_columns
return columns
else: else:
return columns return columns
......
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