Skip to content

Commit

Permalink
Merge 2bf2f6a into 6758f1d
Browse files Browse the repository at this point in the history
  • Loading branch information
Rotonen committed Feb 28, 2019
2 parents 6758f1d + 2bf2f6a commit 18d4d34
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 19 deletions.
3 changes: 2 additions & 1 deletion CHANGES.rst
Expand Up @@ -11,7 +11,8 @@ Changelog
3.6.1 (unreleased)
------------------

- Nothing changed yet.
- Add values to vocabulary GET responses.
[Rotonen]


3.6.0 (2019-02-16)
Expand Down
2 changes: 1 addition & 1 deletion docs/source/vocabularies.rst
Expand Up @@ -5,7 +5,7 @@ Vocabularies are utilities containing a list of values grouped by interest or
different Plone features. For example,
``plone.app.vocabularies.ReallyUserFriendlyTypes`` will return all the content
types registered in Plone. The vocabularies return a list of objects with the
items ``@id``, ``title`` and ``token``.
items ``@id``, ``title``, ``token`` and ``value``.

.. note::
These docs are generated by code tests, therefore you will see some 'test' contenttypes appear here.
Expand Down
4 changes: 3 additions & 1 deletion src/plone/restapi/serializer/vocabularies.py
Expand Up @@ -43,8 +43,10 @@ def __call__(self, vocabulary_id):
term = self.context
token = term.token
title = term.title if ITitledTokenizedTerm.providedBy(term) else token
value = term.value
return {
'@id': '{}/{}'.format(vocabulary_id, token),
'token': token,
'title': title
'title': title,
'value': value
}
36 changes: 24 additions & 12 deletions src/plone/restapi/tests/http-examples/vocabularies_get.resp
Expand Up @@ -7,62 +7,74 @@ Content-Type: application/json
{
"@id": "http://localhost:55001/plone/@vocabularies/plone.app.vocabularies.ReallyUserFriendlyTypes/Collection",
"title": "Collection",
"token": "Collection"
"token": "Collection",
"value": "Collection"
},
{
"@id": "http://localhost:55001/plone/@vocabularies/plone.app.vocabularies.ReallyUserFriendlyTypes/Discussion Item",
"title": "Comment",
"token": "Discussion Item"
"token": "Discussion Item",
"value": "Discussion Item"
},
{
"@id": "http://localhost:55001/plone/@vocabularies/plone.app.vocabularies.ReallyUserFriendlyTypes/DXTestDocument",
"title": "DX Test Document",
"token": "DXTestDocument"
"token": "DXTestDocument",
"value": "DXTestDocument"
},
{
"@id": "http://localhost:55001/plone/@vocabularies/plone.app.vocabularies.ReallyUserFriendlyTypes/Event",
"title": "Event",
"token": "Event"
"token": "Event",
"value": "Event"
},
{
"@id": "http://localhost:55001/plone/@vocabularies/plone.app.vocabularies.ReallyUserFriendlyTypes/File",
"title": "File",
"token": "File"
"token": "File",
"value": "File"
},
{
"@id": "http://localhost:55001/plone/@vocabularies/plone.app.vocabularies.ReallyUserFriendlyTypes/Folder",
"title": "Folder",
"token": "Folder"
"token": "Folder",
"value": "Folder"
},
{
"@id": "http://localhost:55001/plone/@vocabularies/plone.app.vocabularies.ReallyUserFriendlyTypes/Image",
"title": "Image",
"token": "Image"
"token": "Image",
"value": "Image"
},
{
"@id": "http://localhost:55001/plone/@vocabularies/plone.app.vocabularies.ReallyUserFriendlyTypes/Link",
"title": "Link",
"token": "Link"
"token": "Link",
"value": "Link"
},
{
"@id": "http://localhost:55001/plone/@vocabularies/plone.app.vocabularies.ReallyUserFriendlyTypes/News Item",
"title": "News Item",
"token": "News Item"
"token": "News Item",
"value": "News Item"
},
{
"@id": "http://localhost:55001/plone/@vocabularies/plone.app.vocabularies.ReallyUserFriendlyTypes/Document",
"title": "Page",
"token": "Document"
"token": "Document",
"value": "Document"
},
{
"@id": "http://localhost:55001/plone/@vocabularies/plone.app.vocabularies.ReallyUserFriendlyTypes/ATTestDocument",
"title": "Test Document",
"token": "ATTestDocument"
"token": "ATTestDocument",
"value": "ATTestDocument"
},
{
"@id": "http://localhost:55001/plone/@vocabularies/plone.app.vocabularies.ReallyUserFriendlyTypes/ATTestFolder",
"title": "Test Folder",
"token": "ATTestFolder"
"token": "ATTestFolder",
"value": "ATTestFolder"
}
]
}
12 changes: 8 additions & 4 deletions src/plone/restapi/tests/test_services_vocabularies.py
Expand Up @@ -66,10 +66,12 @@ def test_get_vocabulary(self):
u'terms': [
{u'@id': self.portal_url + u'/@vocabularies/plone.restapi.tests.test_vocabulary/token1', # noqa
u'title': u'Title 1',
u'token': u'token1'},
u'token': u'token1',
u'value': 42},
{u'@id': self.portal_url + u'/@vocabularies/plone.restapi.tests.test_vocabulary/token2', # noqa
u'title': u'Title 2',
u'token': u'token2'}]})
u'token': u'token2',
u'value': 43}]})

def test_get_unknown_vocabulary(self):
response = self.api_session.get(
Expand Down Expand Up @@ -132,10 +134,12 @@ def test_context_vocabulary(self):
u'terms': [
{u'@id': self.portal_url + u'/testdoc/@vocabularies/plone.restapi.tests.test_context_vocabulary/id', # noqa
u'title': u'testdoc',
u'token': u'id'},
u'token': u'id',
u'value': u'testdoc'},
{u'@id': self.portal_url + u'/testdoc/@vocabularies/plone.restapi.tests.test_context_vocabulary/title', # noqa
u'title': u'Document 1',
u'token': u'title'}]
u'token': u'title',
u'value': u'Document 1'}]
})

def tearDown(self):
Expand Down

0 comments on commit 18d4d34

Please sign in to comment.