Commit 54351d51 authored by Jérome Perrin's avatar Jérome Perrin

Implement support for strict_membership in getCategoryMemberValueList. from Guy Oswald Obama



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@10030 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 5db84329
...@@ -1380,11 +1380,14 @@ class CategoryTool( UniqueObject, Folder, Base ): ...@@ -1380,11 +1380,14 @@ class CategoryTool( UniqueObject, Folder, Base ):
else: else:
raise CategoryError('getCategoryMemberValueList must know the base category') raise CategoryError('getCategoryMemberValueList must know the base category')
strict_membership = kw.get('strict_membership', kw.get('strict', 0)) strict_membership = kw.get('strict_membership', kw.get('strict', 0))
catalog_search = self.portal_catalog(portal_type = portal_type,
# TODO: make it work in catalog tool
# category_strict_membership = strict_membership,
selection_domain = DomainSelection(domain_dict = {base_category:context}))
if strict_membership:
catalog_search = self.portal_catalog(portal_type = portal_type,
selection_report = DomainSelection(domain_dict = {base_category:context}))
else:
catalog_search = self.portal_catalog(portal_type = portal_type,
selection_domain = DomainSelection(domain_dict = {base_category:context}))
return catalog_search return catalog_search
security.declareProtected( Permissions.AccessContentsInformation, 'getCategoryMemberItemList' ) security.declareProtected( Permissions.AccessContentsInformation, 'getCategoryMemberItemList' )
......
...@@ -611,6 +611,49 @@ class TestCMFCategory(ERP5TypeTestCase): ...@@ -611,6 +611,49 @@ class TestCMFCategory(ERP5TypeTestCase):
region_value.setCategoryList(category_list) region_value.setCategoryList(category_list)
self.assertEqual(category_list, region_value.getCategoryList()) self.assertEqual(category_list, region_value.getCategoryList())
def test_19_CategoryMemberValueList(self, quiet=0, run=run_all_test):
"""Test strict_membership parameter to Category Member Value List """
if not run : return
if not quiet:
message = 'Test strict_membership and Category Member Value List'
ZopeTestCase._print('\n '+message)
LOG('Testing... ',0,message)
portal_categories = self.getCategoryTool()
organisation = self.getOrganisationModule().newContent(
portal_type='Organisation', region='west/france')
get_transaction().commit()
self.tic()
self.assertEquals([x.getObject() for x in
portal_categories.getCategoryMemberValueList(
portal_categories.region.west.france,
base_category='region',
strict_membership=0,
portal_type='Organisation')], [organisation])
self.assertEquals([x.getObject() for x in
portal_categories.getCategoryMemberValueList(
portal_categories.region.west.france,
base_category='region',
strict_membership=1,
portal_type='Organisation')], [organisation])
self.assertEquals([x.getObject() for x in
portal_categories.getCategoryMemberValueList(
portal_categories.region.west,
base_category='region',
strict_membership=0,
portal_type='Organisation')], [organisation])
self.assertEquals([x.getObject() for x in
portal_categories.getCategoryMemberValueList(
portal_categories.region.west,
base_category='region',
strict_membership=1,
portal_type='Organisation')], [])
if __name__ == '__main__': if __name__ == '__main__':
framework() framework()
else: else:
......
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