From e7ce06d5664500e480bb2ae3a55c32a442aa8384 Mon Sep 17 00:00:00 2001 From: Mikel Larreategi Date: Mon, 6 Jul 2020 10:53:36 +0200 Subject: [PATCH] Expose the actual workflow state's title properly localized. --- plone/app/content/browser/contents/__init__.py | 2 ++ plone/app/content/browser/vocabulary.py | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/plone/app/content/browser/contents/__init__.py b/plone/app/content/browser/contents/__init__.py index fbcee04f..72aaee29 100644 --- a/plone/app/content/browser/contents/__init__.py +++ b/plone/app/content/browser/contents/__init__.py @@ -280,6 +280,8 @@ def get_options(self): site_path = site.getPhysicalPath() context_path = self.context.getPhysicalPath() columns = self.get_columns() + columns['translated_review_state'] = translate(_('Review state'), context=self.request) + options = { 'vocabularyUrl': '%splone.app.vocabularies.Catalog' % ( base_vocabulary), diff --git a/plone/app/content/browser/vocabulary.py b/plone/app/content/browser/vocabulary.py index cec956ce..2da82f71 100644 --- a/plone/app/content/browser/vocabulary.py +++ b/plone/app/content/browser/vocabulary.py @@ -121,6 +121,10 @@ class VocabLookupException(Exception): class BaseVocabularyView(BrowserView): + @property + def wftool(self): + return getToolByName(self.context, 'portal_workflow') + def get_translated_ignored(self): return TRANSLATED_IGNORED @@ -263,6 +267,15 @@ def __call__(self): "unknown.png", ] ) + + if key == 'translated_review_state': + val = getattr(vocab_item, 'review_state', None) + title = self.wftool.getTitleForStateOnType(val, getattr(vocab_item, 'portal_type')) + + if isinstance(title, six.binary_type): + title = title.decode("utf8") + item[key] = translate(title, domain='plone', context=self.request) + items.append(item) else: items = [{'id': item.value,