plone.restapi/plone-only-login: Refactor @navigation view to return a single object with the

Timo Stollenwerk <jenkins-z4DKO/[email protected]>
Newsgroups gmane.comp.web.zope.plone.cvs
Message-ID <[email protected]>
Repository: plone.restapi
Branch: refs/heads/plone-only-login
Date: 2017-07-14T18:26:46+02:00
Author: Timo Stollenwerk (tisto) <[email protected]>
Commit: https://github.com/plone/plone.restapi/commit/edc14d31ebbcfa4336ec2628af3f8d24a4f9a777

Refactor @navigation view to return a single object with the @id attr.

Files changed:
M src/plone/restapi/services/navigation/get.py
M src/plone/restapi/tests/test_services_navigation.py

diff --git a/src/plone/restapi/services/navigation/get.py b/src/plone/restapi/services/navigation/get.py
index a2bf0504..ab48b2e1 100644
--- a/src/plone/restapi/services/navigation/get.py
+++ b/src/plone/restapi/services/navigation/get.py
@@ -8,9 +8,14 @@ class NavigationGet(Service):
     def reply(self):
         tabs = getMultiAdapter((self.context, self.request),
                                name="portal_tabs_view")
-        result = []
+        result = {
+            '@id': '{}/@navigation'.format(
+                self.context.absolute_url()
+            ),
+            'items': []
+        }
         for tab in tabs.topLevelTabs():
-            result.append({
+            result['items'].append({
                 'title': tab.get('title', tab.get('name')),
                 'url': tab['url'] + ''
             })
diff --git a/src/plone/restapi/tests/test_services_navigation.py b/src/plone/restapi/tests/test_services_navigation.py
index ad55a612..a0c47213 100644
--- a/src/plone/restapi/tests/test_services_navigation.py
+++ b/src/plone/restapi/tests/test_services_navigation.py
@@ -41,14 +41,17 @@ def test_navigation(self):
         self.assertEqual(response.status_code, 200)
         self.assertEqual(
             response.json(),
-            [
-                {
-                    u'title': u'Home',
-                    u'url': u'http://localhost:55001/plone'
-                },
-                {
-                    u'title': u'Some Folder',
-                    u'url': u'http://localhost:55001/plone/folder'
-                }
-            ]
+            {
+                '@id': 'http://localhost:55001/plone/folder/@navigation',
+                'items': [
+                    {
+                        u'title': u'Home',
+                        u'url': u'http://localhost:55001/plone'
+                    },
+                    {
+                        u'title': u'Some Folder',
+                        u'url': u'http://localhost:55001/plone/folder'
+                    }
+                ]
+            }
         )



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.