Commit 5dc3a48d authored by Sebastien Robin's avatar Sebastien Robin

added a method wich get the title of states


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@3010 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 8c499bd6
......@@ -55,3 +55,27 @@ class Getter(Method):
portal_workflow = getToolByName(instance, 'portal_workflow')
wf = portal_workflow.getWorkflowById(self._key)
return wf._getWorkflowStateOf(instance, id_only=1)
class TitleGetter(Method):
"""
Gets the title of the current state
"""
_need__name__=1
# Generic Definition of Method Object
# This is required to call the method form the Web
func_code = func_code()
func_code.co_varnames = ('self',)
func_code.co_argcount = 1
func_defaults = ()
def __init__(self, id, key):
self._id = id
self.__name__ = id
self._key = key
def __call__(self, instance):
portal_workflow = getToolByName(instance, 'portal_workflow')
wf = portal_workflow.getWorkflowById(self._key)
return wf._getWorkflowStateOf(instance).title
......@@ -206,6 +206,11 @@ def initializePortalTypeDynamicProperties(self, klass, ptype, recursive=0):
method = WorkflowState.Getter(method_id, wf_id)
setattr(prop_holder, method_id, method) # Attach to portal_type
prop_holder.security.declareProtected( Permissions.AccessContentsInformation, method_id )
method_id = 'get%sTitle' % UpperCase(state_var)
if not hasattr(prop_holder, method_id):
method = WorkflowState.TitleGetter(method_id, wf_id)
setattr(prop_holder, method_id, method) # Attach to portal_type
prop_holder.security.declareProtected( Permissions.AccessContentsInformation, method_id )
#LOG('in aq_portal_type %s' % id, 0, "added state method %s" % method_id)
except:
LOG('Base', ERROR,
......@@ -325,6 +330,8 @@ class Base( CopyContainer, PortalContent, ActiveObject, ERP5PropertyManager ):
# We want to use a default property view
manage_propertiesForm = DTMLFile( 'dtml/properties', _dtmldir )
security.declareProtected( Permissions.ModifyPortalContent, 'setTitle' )
security.declareProtected( Permissions.AccessContentsInformation, 'test_dyn' )
def test_dyn(self):
"""
......@@ -1885,8 +1892,7 @@ class Base( CopyContainer, PortalContent, ActiveObject, ERP5PropertyManager ):
"""
LOG(description,0,content)
#setTitle = None
#_setTitle = None
security.declareProtected(Permissions.ModifyPortalContent,'setDescription')
InitializeClass(Base)
......
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