diff --git a/product/ERP5Type/Accessor/WorkflowState.py b/product/ERP5Type/Accessor/WorkflowState.py index 1ce6a54bef06f3b6acbfa0eba4b13b6611500abe..83440d96f2eafd93511f1dce352311504f0ee5df 100755 --- a/product/ERP5Type/Accessor/WorkflowState.py +++ b/product/ERP5Type/Accessor/WorkflowState.py @@ -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 + diff --git a/product/ERP5Type/Base.py b/product/ERP5Type/Base.py index b6e3302bdb59393d6eed22e16a87c92c561f1dad..9a735981ad8831c1e9aa77ae1f993a68af6e40f0 100755 --- a/product/ERP5Type/Base.py +++ b/product/ERP5Type/Base.py @@ -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)