Commit 9b1b0411 authored by Kevin Deldycke's avatar Kevin Deldycke

Add TranslatedGetter ans TranslatedTitleGetter classes


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@3965 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 16fbb3f6
......@@ -62,7 +62,7 @@ class Getter(Method):
class TitleGetter(Method):
"""
Gets the title of the current state
"""
"""
_need__name__=1
# Generic Definition of Method Object
......@@ -83,4 +83,32 @@ class TitleGetter(Method):
return wf._getWorkflowStateOf(instance).title
psyco.bind(__call__)
class TranslatedGetter(Getter):
"""
Gets a translated attribute value. A default value can be
provided if needed
"""
def __call__(self, instance):
portal_workflow = getToolByName(instance, 'portal_workflow')
translation_service = getToolByName(instance, 'translation_service')
wf = portal_workflow.getWorkflowById(self._key)
state_id = wf._getWorkflowStateOf(instance, id_only=1)
return translation_service.translate('ui', state_id)
psyco.bind(__call__)
class TranslatedTitleGetter(TitleGetter):
"""
Gets the translated title of the current state
"""
def __call__(self, instance):
portal_workflow = getToolByName(instance, 'portal_workflow')
translation_service = getToolByName(instance, 'translation_service')
wf = portal_workflow.getWorkflowById(self._key)
state_title = wf._getWorkflowStateOf(instance).title
return translation_service.translate('ui', state_title)
psyco.bind(__call__)
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