plone.restapi/unify-expired-and-excluded-items-handling: Merge pull request #386 from plone/translate-workflow-titles

GitHub <jenkins-z4DKO/[email protected]> Sat, 29 Jul 2017 16:32:11 -0700 (PDT)
Newsgroups gmane.comp.web.zope.plone.cvs
Message-ID <[email protected]>
Repository: plone.restapi
Branch: refs/heads/unify-expired-and-excluded-items-handling
Date: 2017-07-27T10:29:46+02:00
Author: Timo Stollenwerk (tisto) <[email protected]>
Commit: https://github.com/plone/plone.restapi/commit/2cf9cb06e016489ed7f7d8ae62c0c123eafd20cb

Merge pull request #386 from plone/translate-workflow-titles

Translate titles in @workflow

Files changed:
M CHANGES.rst
M docs/source/_json/workflow_post.resp
M src/plone/restapi/services/workflow/info.py
M src/plone/restapi/services/workflow/transition.py

diff --git a/CHANGES.rst b/CHANGES.rst
index 7858f485..ea327e04 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -9,6 +9,9 @@ New Features:
 - Add support for expandable elements.
   [buchi]
 
+- Translate titles in @workflow.
+  [csenger]
+  
 - Add skipped tests from @breadcrumbs and @navigation now that the expansion is in place
   [sneridagh]
 
diff --git a/docs/source/_json/workflow_post.resp b/docs/source/_json/workflow_post.resp
index 96325403..a6ad4a79 100644
--- a/docs/source/_json/workflow_post.resp
+++ b/docs/source/_json/workflow_post.resp
@@ -6,5 +6,6 @@ Content-Type: application/json
   "actor": "admin", 
   "comments": "", 
   "review_state": "published", 
-  "time": "2016-10-21T19:05:00+00:00"
+  "time": "2016-10-21T19:05:00+00:00", 
+  "title": "Published"
 }
\ No newline at end of file
diff --git a/src/plone/restapi/services/workflow/info.py b/src/plone/restapi/services/workflow/info.py
index a8fb73f4..4b8e2063 100644
--- a/src/plone/restapi/services/workflow/info.py
+++ b/src/plone/restapi/services/workflow/info.py
@@ -38,13 +38,14 @@ def __call__(self, expand=False):
             transitions.append({
                 '@id': '{}/@workflow/{}'.format(
                     self.context.absolute_url(), action['id']),
-                'title': action['title'],
+                'title': self.context.translate(action['title']),
             })
 
         for item, action in enumerate(history):
-            history[item]['title'] = wftool.getTitleForStateOnType(
-                action['review_state'],
-                self.context.portal_type)
+            history[item]['title'] = self.context.translate(
+                wftool.getTitleForStateOnType(
+                    action['review_state'],
+                    self.context.portal_type))
 
         result['workflow'].update({
             'history': json_compatible(history),
diff --git a/src/plone/restapi/services/workflow/transition.py b/src/plone/restapi/services/workflow/transition.py
index 8f4fc940..fa8d1910 100644
--- a/src/plone/restapi/services/workflow/transition.py
+++ b/src/plone/restapi/services/workflow/transition.py
@@ -59,4 +59,10 @@ def reply(self):
                 message=translate(e.message, context=self.request)))
 
         history = wftool.getInfoFor(self.context, "review_history")
-        return json_compatible(history[-1])
+        action = history[-1]
+        action['title'] = self.context.translate(
+            wftool.getTitleForStateOnType(
+                action['review_state'],
+                self.context.portal_type))
+
+        return json_compatible(action)



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot