Commit 5a0a13a8 authored by Jérome Perrin's avatar Jérome Perrin

Fix the case of "parent" base category in getSingleCategoryMembershipList,



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@16551 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 3340da58
......@@ -781,14 +781,14 @@ class CategoryTool( UniqueObject, Folder, Base ):
#LOG('getSingleCategoryMembershipList', 0, 'base_category = %s, spec = %s, base = %s, context = %s, context.aq_inner.aq_parent = %s' % (repr(base_category), repr(spec), repr(base), repr(context), repr(context.aq_inner.aq_parent)))
if base_category == 'parent':
parent = context.aq_inner.aq_parent # aq_inner is required to make sure we use containment
if parent.portal_type in spec:
if not spec or parent.portal_type in spec:
parent_relative_url = parent.getRelativeUrl()
if (checked_permission is None) or \
(permissionFilter(parent_relative_url) is not None):
if base:
return 'parent/%s' % parent_relative_url
return ['parent/%s' % parent_relative_url]
else:
return parent_relative_url
return [parent_relative_url]
#LOG('getSingleCategoryMembershipList', 0, 'not in spec: parent.portal_type = %s, spec = %s' % (repr(parent.portal_type), repr(spec)))
return []
......
......@@ -31,6 +31,7 @@ import unittest
from Testing import ZopeTestCase
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from AccessControl.SecurityManagement import newSecurityManager
from AccessControl.SecurityManagement import noSecurityManager
from zLOG import LOG
try:
......@@ -899,6 +900,61 @@ class TestCMFCategory(ERP5TypeTestCase):
self.assertEquals([['', ''], ['C', 'bar/foo/1']],
bc.getCategoryChildTitleItemList(base='bar'))
def test_getSingleCategoryAcquiredMembershipList(self):
pc = self.getCategoriesTool()
obj = self.portal.person_module.newContent(portal_type='Person')
region_url = self.region1
obj.setRegion(region_url)
self.assertEquals([region_url],
pc.getSingleCategoryMembershipList(obj, 'region'))
self.assertEquals([region_url],
pc.getSingleCategoryMembershipList(obj, 'region',
portal_type='Category'))
self.assertEquals([],
pc.getSingleCategoryMembershipList(obj, 'region',
portal_type='Organisation'))
self.assertEquals(['region/%s' % region_url],
pc.getSingleCategoryMembershipList(obj, 'region', base=1))
self.assertEquals([region_url],
pc.getSingleCategoryMembershipList(obj, 'region',
checked_permission='View'))
noSecurityManager()
self.assertEquals([],
pc.getSingleCategoryMembershipList(obj, 'region',
checked_permission='Manage portal'))
def test_getSingleCategoryAcquiredMembershipListOnParent(self):
pc = self.getCategoriesTool()
obj = self.portal.person_module.newContent(portal_type='Person')
parent_url = self.portal.person_module.getRelativeUrl()
self.assertEquals([parent_url],
pc.getSingleCategoryMembershipList(obj, 'parent'))
self.assertEquals([parent_url],
pc.getSingleCategoryMembershipList(obj, 'parent',
portal_type='Person Module'))
self.assertEquals([],
pc.getSingleCategoryMembershipList(obj, 'parent',
portal_type='Organisation'))
self.assertEquals(['parent/%s' % parent_url],
pc.getSingleCategoryMembershipList(obj, 'parent', base=1))
self.assertEquals([parent_url],
pc.getSingleCategoryMembershipList(obj, 'parent',
checked_permission='View'))
noSecurityManager()
self.assertEquals([],
pc.getSingleCategoryMembershipList(obj, 'parent',
checked_permission='Manage portal'))
def test_suite():
suite = unittest.TestSuite()
......
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