plone.restapi/plone-only-login: Remove @ symbol from workflow info key name
Thomas Buchberger <jenkins-z4DKO/[email protected]> Wed, 26 Jul 2017 07:45:59 -0700 (PDT)
| Newsgroups | gmane.comp.web.zope.plone.cvs |
|---|---|
| Message-ID | <[email protected]> |
Repository: plone.restapi Branch: refs/heads/plone-only-login Date: 2017-07-25T15:51:21+02:00 Author: Thomas Buchberger (buchi) <t.buchberger-/8aE7x569Db/[email protected]> Commit: https://github.com/plone/plone.restapi/commit/3e2bf4d8b83a5da878a505d52d8334153c7e21c9 Remove @ symbol from workflow info key name Files changed: M docs/source/_json/collection.resp M docs/source/_json/content_get.resp M docs/source/_json/content_post.resp M docs/source/_json/document.resp M docs/source/_json/event.resp M docs/source/_json/expansion.resp M docs/source/_json/expansion_expanded.resp M docs/source/_json/expansion_expanded_full.resp M docs/source/_json/file.resp M docs/source/_json/folder.resp M docs/source/_json/image.resp M docs/source/_json/link.resp M docs/source/_json/newsitem.resp M docs/source/_json/workflow_get.resp M src/plone/restapi/services/workflow/info.py M src/plone/restapi/tests/test_components.py M src/plone/restapi/tests/test_workflow.py diff --git a/docs/source/_json/collection.resp b/docs/source/_json/collection.resp index 912d4895..da417bdf 100644 --- a/docs/source/_json/collection.resp +++ b/docs/source/_json/collection.resp @@ -3,14 +3,14 @@ Content-Type: application/json { "@components": { - "@workflow": { - "@id": "http://localhost:55001/plone/collection/@workflow" - }, "breadcrumbs": { "@id": "http://localhost:55001/plone/collection/@breadcrumbs" }, "navigation": { "@id": "http://localhost:55001/plone/collection/@navigation" + }, + "workflow": { + "@id": "http://localhost:55001/plone/collection/@workflow" } }, "@id": "http://localhost:55001/plone/collection", diff --git a/docs/source/_json/content_get.resp b/docs/source/_json/content_get.resp index 84d1571b..dc9149da 100644 --- a/docs/source/_json/content_get.resp +++ b/docs/source/_json/content_get.resp @@ -3,14 +3,14 @@ Content-Type: application/json { "@components": { - "@workflow": { - "@id": "http://localhost:55001/plone/folder/my-document/@workflow" - }, "breadcrumbs": { "@id": "http://localhost:55001/plone/folder/my-document/@breadcrumbs" }, "navigation": { "@id": "http://localhost:55001/plone/folder/my-document/@navigation" + }, + "workflow": { + "@id": "http://localhost:55001/plone/folder/my-document/@workflow" } }, "@id": "http://localhost:55001/plone/folder/my-document", diff --git a/docs/source/_json/content_post.resp b/docs/source/_json/content_post.resp index c627cff8..1de28ad2 100644 --- a/docs/source/_json/content_post.resp +++ b/docs/source/_json/content_post.resp @@ -4,14 +4,14 @@ Location: http://localhost:55001/plone/folder/my-document { "@components": { - "@workflow": { - "@id": "http://localhost:55001/plone/folder/my-document/@workflow" - }, "breadcrumbs": { "@id": "http://localhost:55001/plone/folder/my-document/@breadcrumbs" }, "navigation": { "@id": "http://localhost:55001/plone/folder/my-document/@navigation" + }, + "workflow": { + "@id": "http://localhost:55001/plone/folder/my-document/@workflow" } }, "@id": "http://localhost:55001/plone/folder/my-document", diff --git a/docs/source/_json/document.resp b/docs/source/_json/document.resp index e385c01e..998b22c3 100644 --- a/docs/source/_json/document.resp +++ b/docs/source/_json/document.resp @@ -3,14 +3,14 @@ Content-Type: application/json { "@components": { - "@workflow": { - "@id": "http://localhost:55001/plone/front-page/@workflow" - }, "breadcrumbs": { "@id": "http://localhost:55001/plone/front-page/@breadcrumbs" }, "navigation": { "@id": "http://localhost:55001/plone/front-page/@navigation" + }, + "workflow": { + "@id": "http://localhost:55001/plone/front-page/@workflow" } }, "@id": "http://localhost:55001/plone/front-page", diff --git a/docs/source/_json/event.resp b/docs/source/_json/event.resp index be0da16c..52bfcbd0 100644 --- a/docs/source/_json/event.resp +++ b/docs/source/_json/event.resp @@ -3,14 +3,14 @@ Content-Type: application/json { "@components": { - "@workflow": { - "@id": "http://localhost:55001/plone/event/@workflow" - }, "breadcrumbs": { "@id": "http://localhost:55001/plone/event/@breadcrumbs" }, "navigation": { "@id": "http://localhost:55001/plone/event/@navigation" + }, + "workflow": { + "@id": "http://localhost:55001/plone/event/@workflow" } }, "@id": "http://localhost:55001/plone/event", diff --git a/docs/source/_json/expansion.resp b/docs/source/_json/expansion.resp index e385c01e..998b22c3 100644 --- a/docs/source/_json/expansion.resp +++ b/docs/source/_json/expansion.resp @@ -3,14 +3,14 @@ Content-Type: application/json { "@components": { - "@workflow": { - "@id": "http://localhost:55001/plone/front-page/@workflow" - }, "breadcrumbs": { "@id": "http://localhost:55001/plone/front-page/@breadcrumbs" }, "navigation": { "@id": "http://localhost:55001/plone/front-page/@navigation" + }, + "workflow": { + "@id": "http://localhost:55001/plone/front-page/@workflow" } }, "@id": "http://localhost:55001/plone/front-page", diff --git a/docs/source/_json/expansion_expanded.resp b/docs/source/_json/expansion_expanded.resp index 30b0ac27..abbe6344 100644 --- a/docs/source/_json/expansion_expanded.resp +++ b/docs/source/_json/expansion_expanded.resp @@ -3,9 +3,6 @@ Content-Type: application/json { "@components": { - "@workflow": { - "@id": "http://localhost:55001/plone/front-page/@workflow" - }, "breadcrumbs": { "@id": "http://localhost:55001/plone/front-page/@breadcrumbs", "items": [ @@ -17,6 +14,9 @@ Content-Type: application/json }, "navigation": { "@id": "http://localhost:55001/plone/front-page/@navigation" + }, + "workflow": { + "@id": "http://localhost:55001/plone/front-page/@workflow" } }, "@id": "http://localhost:55001/plone/front-page", diff --git a/docs/source/_json/expansion_expanded_full.resp b/docs/source/_json/expansion_expanded_full.resp index 7dd04d52..6b92c4c5 100644 --- a/docs/source/_json/expansion_expanded_full.resp +++ b/docs/source/_json/expansion_expanded_full.resp @@ -3,28 +3,6 @@ Content-Type: application/json { "@components": { - "@workflow": { - "history": [ - { - "action": null, - "actor": "test_user_1_", - "comments": "", - "review_state": "private", - "time": "2016-10-21T19:00:00+00:00", - "title": "Private" - } - ], - "transitions": [ - { - "@id": "http://localhost:55001/plone/front-page/@workflow/publish", - "title": "Publish" - }, - { - "@id": "http://localhost:55001/plone/front-page/@workflow/submit", - "title": "Submit for publication" - } - ] - }, "breadcrumbs": { "@id": "http://localhost:55001/plone/front-page/@breadcrumbs", "items": [ @@ -46,6 +24,29 @@ Content-Type: application/json "url": "http://localhost:55001/plone/front-page" } ] + }, + "workflow": { + "@id": "http://localhost:55001/plone/front-page/@workflow", + "history": [ + { + "action": null, + "actor": "test_user_1_", + "comments": "", + "review_state": "private", + "time": "2016-10-21T19:00:00+00:00", + "title": "Private" + } + ], + "transitions": [ + { + "@id": "http://localhost:55001/plone/front-page/@workflow/publish", + "title": "Publish" + }, + { + "@id": "http://localhost:55001/plone/front-page/@workflow/submit", + "title": "Submit for publication" + } + ] } }, "@id": "http://localhost:55001/plone/front-page", diff --git a/docs/source/_json/file.resp b/docs/source/_json/file.resp index cf619bea..979141bd 100644 --- a/docs/source/_json/file.resp +++ b/docs/source/_json/file.resp @@ -3,14 +3,14 @@ Content-Type: application/json { "@components": { - "@workflow": { - "@id": "http://localhost:55001/plone/file/@workflow" - }, "breadcrumbs": { "@id": "http://localhost:55001/plone/file/@breadcrumbs" }, "navigation": { "@id": "http://localhost:55001/plone/file/@navigation" + }, + "workflow": { + "@id": "http://localhost:55001/plone/file/@workflow" } }, "@id": "http://localhost:55001/plone/file", diff --git a/docs/source/_json/folder.resp b/docs/source/_json/folder.resp index 483f9491..39aa5b40 100644 --- a/docs/source/_json/folder.resp +++ b/docs/source/_json/folder.resp @@ -3,14 +3,14 @@ Content-Type: application/json { "@components": { - "@workflow": { - "@id": "http://localhost:55001/plone/folder/@workflow" - }, "breadcrumbs": { "@id": "http://localhost:55001/plone/folder/@breadcrumbs" }, "navigation": { "@id": "http://localhost:55001/plone/folder/@navigation" + }, + "workflow": { + "@id": "http://localhost:55001/plone/folder/@workflow" } }, "@id": "http://localhost:55001/plone/folder", diff --git a/docs/source/_json/image.resp b/docs/source/_json/image.resp index 73b4a020..b198ac97 100644 --- a/docs/source/_json/image.resp +++ b/docs/source/_json/image.resp @@ -3,14 +3,14 @@ Content-Type: application/json { "@components": { - "@workflow": { - "@id": "http://localhost:55001/plone/image/@workflow" - }, "breadcrumbs": { "@id": "http://localhost:55001/plone/image/@breadcrumbs" }, "navigation": { "@id": "http://localhost:55001/plone/image/@navigation" + }, + "workflow": { + "@id": "http://localhost:55001/plone/image/@workflow" } }, "@id": "http://localhost:55001/plone/image", diff --git a/docs/source/_json/link.resp b/docs/source/_json/link.resp index 6152d001..d235c5cc 100644 --- a/docs/source/_json/link.resp +++ b/docs/source/_json/link.resp @@ -3,14 +3,14 @@ Content-Type: application/json { "@components": { - "@workflow": { - "@id": "http://localhost:55001/plone/link/@workflow" - }, "breadcrumbs": { "@id": "http://localhost:55001/plone/link/@breadcrumbs" }, "navigation": { "@id": "http://localhost:55001/plone/link/@navigation" + }, + "workflow": { + "@id": "http://localhost:55001/plone/link/@workflow" } }, "@id": "http://localhost:55001/plone/link", diff --git a/docs/source/_json/newsitem.resp b/docs/source/_json/newsitem.resp index 740c6619..b926a819 100644 --- a/docs/source/_json/newsitem.resp +++ b/docs/source/_json/newsitem.resp @@ -3,14 +3,14 @@ Content-Type: application/json { "@components": { - "@workflow": { - "@id": "http://localhost:55001/plone/newsitem/@workflow" - }, "breadcrumbs": { "@id": "http://localhost:55001/plone/newsitem/@breadcrumbs" }, "navigation": { "@id": "http://localhost:55001/plone/newsitem/@navigation" + }, + "workflow": { + "@id": "http://localhost:55001/plone/newsitem/@workflow" } }, "@id": "http://localhost:55001/plone/newsitem", diff --git a/docs/source/_json/workflow_get.resp b/docs/source/_json/workflow_get.resp index 26f93780..6c365e9e 100644 --- a/docs/source/_json/workflow_get.resp +++ b/docs/source/_json/workflow_get.resp @@ -2,6 +2,7 @@ HTTP/1.1 200 OK Content-Type: application/json { + "@id": "http://localhost:55001/plone/front-page/@workflow", "history": [ { "action": null, diff --git a/src/plone/restapi/services/workflow/info.py b/src/plone/restapi/services/workflow/info.py index f2c38f72..a8fb73f4 100644 --- a/src/plone/restapi/services/workflow/info.py +++ b/src/plone/restapi/services/workflow/info.py @@ -18,10 +18,13 @@ def __init__(self, context, request): self.request = request def __call__(self, expand=False): - if not expand: - return {'@workflow': { + result = { + 'workflow': { "@id": '{}/@workflow'.format(self.context.absolute_url()), - }} + }, + } + if not expand: + return result wftool = getToolByName(self.context, 'portal_workflow') history = wftool.getInfoFor(self.context, "review_history") @@ -43,10 +46,11 @@ def __call__(self, expand=False): action['review_state'], self.context.portal_type) - return {'@workflow': { + result['workflow'].update({ 'history': json_compatible(history), 'transitions': transitions, - }} + }) + return result class WorkflowInfoService(Service): @@ -54,4 +58,4 @@ class WorkflowInfoService(Service): """ def reply(self): info = WorkflowInfo(self.context, self.request) - return info(expand=True)['@workflow'] + return info(expand=True)['workflow'] diff --git a/src/plone/restapi/tests/test_components.py b/src/plone/restapi/tests/test_components.py index 18d17c61..912510f9 100644 --- a/src/plone/restapi/tests/test_components.py +++ b/src/plone/restapi/tests/test_components.py @@ -57,22 +57,15 @@ def test_breadcrumb(self): def test_collapsed_breadcrumbs_in_content_serialization(self): obj = self.api_session.get('/folder').json() self.assertIn('@components', obj) - self.assertIn('breadcrumbs', obj['@components']['@components']) - self.assertIn('@id', obj['@components']['@components']['breadcrumbs']) + self.assertIn('breadcrumbs', obj['@components']) + self.assertIn('@id', obj['@components']['breadcrumbs']) + self.assertNotIn('items', obj['@components']['breadcrumbs']) def test_expanded_breadcrumbs_in_content_serialization(self): obj = self.api_session.get('/folder/doc1?expand=breadcrumbs').json() self.assertIn('@components', obj) - self.assertIn('breadcrumbs', obj['@components']['@components']) - self.assertEqual( - [{ - u'url': u'http://localhost:55001/plone/folder', - u'title': u'Some Folder' - }, { - u'url': u'http://localhost:55001/plone/folder/doc1', - u'title': u'A document' - }], - obj['@components']['@components']['breadcrumbs']) + self.assertIn('breadcrumbs', obj['@components']) + self.assertIn('items', obj['@components']['breadcrumbs']) def test_navigation(self): response = self.api_session.get('/folder/@components/navigation') @@ -96,19 +89,12 @@ def test_navigation(self): def test_collapsed_navigation_in_content_serialization(self): obj = self.api_session.get('/folder').json() self.assertIn('@components', obj) - self.assertIn('navigation', obj['@components']['@components']) - self.assertIn('@id', obj['@components']['@components']['navigation']) + self.assertIn('navigation', obj['@components']) + self.assertIn('@id', obj['@components']['navigation']) + self.assertNotIn('items', obj['@components']['navigation']) def test_expanded_navigation_in_content_serialization(self): obj = self.api_session.get('/folder?expand=navigation').json() self.assertIn('@components', obj) - self.assertIn('navigation', obj['@components']['@components']) - self.assertEqual( - [{ - u'title': u'Home', - u'url': u'http://localhost:55001/plone' - }, { - u'title': u'Some Folder', - u'url': u'http://localhost:55001/plone/folder' - }], - obj['@components']['@components']['navigation']) + self.assertIn('navigation', obj['@components']) + self.assertIn('items', obj['@components']['navigation']) diff --git a/src/plone/restapi/tests/test_workflow.py b/src/plone/restapi/tests/test_workflow.py index 0c9f6a5e..ed96886f 100644 --- a/src/plone/restapi/tests/test_workflow.py +++ b/src/plone/restapi/tests/test_workflow.py @@ -48,17 +48,17 @@ def test_collapsed_workflow_info_in_content_serialization(self): serializer = getMultiAdapter((self.doc1, self.request), ISerializeToJson) obj = serializer() - self.assertIn('@workflow', obj['@components']) - self.assertIn('@id', obj['@components']['@workflow']) + self.assertIn('workflow', obj['@components']) + self.assertIn('@id', obj['@components']['workflow']) def test_expanded_workflow_info_in_content_serialization(self): self.request.form.update({'expand': 'workflow'}) serializer = getMultiAdapter((self.doc1, self.request), ISerializeToJson) obj = serializer() - self.assertIn('@workflow', obj['@components']) - self.assertIn('transitions', obj['@components']['@workflow']) - self.assertIn('history', obj['@components']['@workflow']) + self.assertIn('workflow', obj['@components']) + self.assertIn('transitions', obj['@components']['workflow']) + self.assertIn('history', obj['@components']['workflow']) class TestWorkflowTransition(TestCase): ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot