Commit 18f7958b authored by Jean-Paul Smets's avatar Jean-Paul Smets

Added new portal type groups. Provide sorted result by default whenever user...

Added new portal type groups. Provide sorted result by default whenever user tries to access list of portal types (taking into account selected language).

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@13325 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent f44be6ff
...@@ -389,18 +389,32 @@ class ERP5Site(FolderMixIn, CMFSite): ...@@ -389,18 +389,32 @@ class ERP5Site(FolderMixIn, CMFSite):
def _getPortalGroupedTypeList(self, group): def _getPortalGroupedTypeList(self, group):
""" """
Return a list of portal types classified to a specific group. Return a list of portal types classified to a specific group.
The result is sorted by language (using the user language
as default)
""" """
def getTypeList(group): def getTypeList(group):
type_list = [] type_list = []
for pt in self.portal_types.objectValues(): for pt in self.portal_types.objectValues():
if group in getattr(pt, 'group_list', ()): if group in getattr(pt, 'group_list', ()):
type_list.append(pt.getId()) type_list.append(pt.getId())
def sortByTranslation(a, b):
return cmp(localizer_tool.translate('ui', a),
localizer_tool.translate('ui', b))
type_list.sort(sortByTranslation)
return tuple(type_list) return tuple(type_list)
localizer_tool = getToolByName(self, 'Localizer')
language = localizer_tool.get_selected_language()
# language should be cached in Transaction Cache if performance issue
getTypeList = CachingMethod(getTypeList, getTypeList = CachingMethod(getTypeList,
id=('_getPortalGroupedTypeList', group), id=(('_getPortalGroupedTypeList', language), group),
cache_factory='erp5_content_medium') cache_factory='erp5_content_medium')
return getTypeList(group)
return getTypeList(group) # Although this method is called get*List, it
# returns a tuple - renaming to be considered
def _getPortalGroupedCategoryList(self, group): def _getPortalGroupedCategoryList(self, group):
""" """
...@@ -612,6 +626,38 @@ class ERP5Site(FolderMixIn, CMFSite): ...@@ -612,6 +626,38 @@ class ERP5Site(FolderMixIn, CMFSite):
""" """
return self._getPortalGroupedTypeList('web_document') return self._getPortalGroupedTypeList('web_document')
security.declareProtected(Permissions.AccessContentsInformation,
'getPortalFileDocumentTypeList')
def getPortalFileDocumentTypeList(self):
"""
Return web page types.
"""
return self._getPortalGroupedTypeList('file_document')
security.declareProtected(Permissions.AccessContentsInformation,
'getPortalRecentDocumentTypeList')
def getPortalRecentDocumentTypeList(self):
"""
Return web page types.
"""
return self._getPortalGroupedTypeList('recent_document')
security.declareProtected(Permissions.AccessContentsInformation,
'getPortalTemplateDocumentTypeList')
def getPortalTemplateDocumentTypeList(self):
"""
Return web page types.
"""
return self._getPortalGroupedTypeList('template_document')
security.declareProtected(Permissions.AccessContentsInformation,
'getPortalMyDocumentTypeList')
def getPortalMyDocumentTypeList(self):
"""
Return web page types.
"""
return self._getPortalGroupedTypeList('my_document')
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getPortalSupplyPathTypeList') 'getPortalSupplyPathTypeList')
def getPortalSupplyPathTypeList(self): def getPortalSupplyPathTypeList(self):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment