Commit 6f4ba6df authored by Yoshinori Okuji's avatar Yoshinori Okuji

Add _getPortalGroupedCategoryList.

Use _getPortalGroupedCategoryList to gather categories. Using site properties is still supported only for backward-compatibility.
Deprecate getPortalDefaultGapRoot.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@4417 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent dc8ae6e0
...@@ -284,6 +284,19 @@ class ERP5Site ( CMFSite, FolderMixIn ): ...@@ -284,6 +284,19 @@ class ERP5Site ( CMFSite, FolderMixIn ):
getTypeList = CachingMethod(getTypeList, id=('_getPortalGroupedTypeList', group), cache_duration=3600) getTypeList = CachingMethod(getTypeList, id=('_getPortalGroupedTypeList', group), cache_duration=3600)
return getTypeList(group) return getTypeList(group)
def _getPortalGroupedCategoryList(self, group):
"""Return a list of base categories classified to a specific group.
"""
def getCategoryList(group):
category_list = []
for bc in self.portal_categories.objectValues():
if group in bc.getCategoryTypeList():
category_list.append(bc.getId())
return tuple(category_list)
getCategoryList = CachingMethod(getCategoryList, id=('_getPortalGroupedCategoryList', group), cache_duration=3600)
return getCategoryList(group)
security.declareProtected(Permissions.AccessContentsInformation, 'getPortalResourceTypeList') security.declareProtected(Permissions.AccessContentsInformation, 'getPortalResourceTypeList')
def getPortalResourceTypeList(self): def getPortalResourceTypeList(self):
""" """
...@@ -339,7 +352,7 @@ class ERP5Site ( CMFSite, FolderMixIn ): ...@@ -339,7 +352,7 @@ class ERP5Site ( CMFSite, FolderMixIn ):
""" """
Return variation base categories. Return variation base categories.
""" """
return self._getPortalConfiguration('portal_variation_base_category_list') return self._getPortalGroupedCategoryList('variation') or self._getPortalConfiguration('portal_variation_base_category_list')
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getPortalOptionBaseCategoryList') 'getPortalOptionBaseCategoryList')
...@@ -347,7 +360,7 @@ class ERP5Site ( CMFSite, FolderMixIn ): ...@@ -347,7 +360,7 @@ class ERP5Site ( CMFSite, FolderMixIn ):
""" """
Return option base categories. Return option base categories.
""" """
return self._getPortalConfiguration('portal_option_base_category_list') return self._getPortalGroupedCategoryList('option') or self._getPortalConfiguration('portal_option_base_category_list')
security.declareProtected(Permissions.AccessContentsInformation, 'getPortalInvoiceMovementTypeList') security.declareProtected(Permissions.AccessContentsInformation, 'getPortalInvoiceMovementTypeList')
def getPortalInvoiceMovementTypeList(self): def getPortalInvoiceMovementTypeList(self):
...@@ -494,27 +507,29 @@ class ERP5Site ( CMFSite, FolderMixIn ): ...@@ -494,27 +507,29 @@ class ERP5Site ( CMFSite, FolderMixIn ):
""" """
Return column base categories. Return column base categories.
""" """
return self._getPortalConfiguration('portal_column_base_category_list') return self._getPortalGroupedCategoryList('column') or self._getPortalConfiguration('portal_column_base_category_list')
security.declareProtected(Permissions.AccessContentsInformation, 'getPortalLineBaseCategoryList') security.declareProtected(Permissions.AccessContentsInformation, 'getPortalLineBaseCategoryList')
def getPortalLineBaseCategoryList(self): def getPortalLineBaseCategoryList(self):
""" """
Return line base categories. Return line base categories.
""" """
return self._getPortalConfiguration('portal_line_base_category_list') return self._getPortalGroupedCategoryList('line') or self._getPortalConfiguration('portal_line_base_category_list')
security.declareProtected(Permissions.AccessContentsInformation, 'getPortalTabBaseCategoryList') security.declareProtected(Permissions.AccessContentsInformation, 'getPortalTabBaseCategoryList')
def getPortalTabBaseCategoryList(self): def getPortalTabBaseCategoryList(self):
""" """
Return tab base categories. Return tab base categories.
""" """
return self._getPortalConfiguration('portal_tab_base_category_list') return self._getPortalGroupedCategoryList('tab') or self._getPortalConfiguration('portal_tab_base_category_list')
def getPortalDefaultGapRoot(self): def getPortalDefaultGapRoot(self):
""" """
Return the Accounting Plan to use by default (return the root node) Return the Accounting Plan to use by default (return the root node)
""" """
return self._getPortalConfiguration('portal_default_gap_root') LOG('ERP5Site', 0, 'getPortalDefaultGapRoot is deprecated; use portal_preferences.getPreferredAccountingTransactionGap instead.')
return self.portal_preferences.getPreferredAccountingTransactionGap() or self._getPortalConfiguration('portal_default_gap_root')
def getPortalAccountingMovementTypeList(self) : def getPortalAccountingMovementTypeList(self) :
""" """
...@@ -526,11 +541,7 @@ class ERP5Site ( CMFSite, FolderMixIn ): ...@@ -526,11 +541,7 @@ class ERP5Site ( CMFSite, FolderMixIn ):
""" """
Return List of category values to generate security groups. Return List of category values to generate security groups.
""" """
category_tuple = self._getPortalConfiguration('portal_assignment_base_category_list') return self._getPortalGroupedCategoryList('assignment') or self._getPortalConfiguration('portal_assignment_base_category_list')
category_list = []
if category_tuple not in (None, '', (), []):
category_list = [ x for x in category_tuple]
return category_list
security.declareProtected(Permissions.AccessContentsInformation, 'getDefaultModuleId') security.declareProtected(Permissions.AccessContentsInformation, 'getDefaultModuleId')
def getDefaultModuleId(self, portal_type): def getDefaultModuleId(self, portal_type):
......
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