plone.restapi/expansion: Filter out non-DX types
Timo Stollenwerk <jenkins-z4DKO/[email protected]>
| Newsgroups | gmane.comp.web.zope.plone.cvs |
|---|---|
| Message-ID | <[email protected]> |
Repository: plone.restapi Branch: refs/heads/expansion Date: 2017-07-16T12:06:34+02:00 Author: Roel Bruggink (jaroel) <roel-Ttk/PUy0oENmR6Xm/[email protected]> Commit: https://github.com/plone/plone.restapi/commit/34f301189c7d5861acac7c8161f6c476a9bbf311 Filter out non-DX types Files changed: M CHANGES.rst M src/plone/restapi/services/types/get.py diff --git a/CHANGES.rst b/CHANGES.rst index c3b2fd8e..600ae754 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -33,6 +33,11 @@ Bugfixes: - Tweaks to README.rst [tkimnguyen] +Bugfixes: + +- Don't list non-DX types. Refs https://github.com/plone/plone.restapi/issues/150 + [jaroel] + 1.0a17 (2017-05-31) ------------------- diff --git a/src/plone/restapi/services/types/get.py b/src/plone/restapi/services/types/get.py index 6b39107b..d61ca2f7 100644 --- a/src/plone/restapi/services/types/get.py +++ b/src/plone/restapi/services/types/get.py @@ -65,6 +65,8 @@ def reply(self): name="plone.app.vocabularies.ReallyUserFriendlyTypes" ) + portal_types = getToolByName(self.context, 'portal_types') + # allowedContentTypes already checks for permissions allowed_types = [x.getId() for x in self.context.allowedContentTypes()] @@ -75,10 +77,15 @@ def reply(self): # only addables if the content type is folderish can_add = IFolderish.providedBy(self.context) + # Filter out any type that doesn't have lookupSchema. We are depended + # on that in lower level code. + ftis = [portal_types[x.value] for x in vocab_factory(self.context)] + ftis = [fti for fti in ftis if getattr(fti, 'lookupSchema', None)] + return [ { - '@id': '{}/@types/{}'.format(portal_url, x.token), - 'title': x.value, - 'addable': x.token in allowed_types if can_add else False, - } for x in vocab_factory(self.context) + '@id': '{}/@types/{}'.format(portal_url, fti.getId()), + 'title': fti.Title(), + 'addable': fti.getId() in allowed_types if can_add else False, + } for fti in ftis ] ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot