Commit 7655bef2 authored by Julien Muchembled's avatar Julien Muchembled

Use getTypeAllowedContentTypeList() instead of accessing 'allowed_content_types' directly

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@30224 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent b5585104
......@@ -56,9 +56,7 @@
<value> <string>"""\n
Get portal type list allowed in module through Types Tool\n
"""\n
folder_portal_type = context.getPortalType()\n
portal = context.getPortalObject()\n
return portal.portal_types[folder_portal_type].allowed_content_types[:]\n
return context.getTypeInfo().getTypeAllowedContentTypeList()\n
</string> </value>
</item>
<item>
......@@ -105,9 +103,6 @@ return portal.portal_types[folder_portal_type].allowed_content_types[:]\n
<tuple>
<string>_getattr_</string>
<string>context</string>
<string>folder_portal_type</string>
<string>portal</string>
<string>_getitem_</string>
</tuple>
</value>
</item>
......
647
\ No newline at end of file
648
\ No newline at end of file
......@@ -58,11 +58,11 @@ types_tool = context.getPortalObject().portal_types\n
movement_type_list = context.getPortalMovementTypeList()\n
type_set = dict()\n
\n
for type_name in types_tool.getTypeInfo(context).allowed_content_types:\n
for line_type_name in types_tool.getTypeInfo(type_name).allowed_content_types:\n
for type_name in types_tool.getTypeInfo(context).getTypeAllowedContentTypeList():\n
for line_type_name in types_tool.getTypeInfo(type_name).getTypeAllowedContentTypeList():\n
if line_type_name in movement_type_list:\n
type_set[line_type_name] = 1\n
for cell_type_name in types_tool.getTypeInfo(line_type_name).allowed_content_types:\n
for cell_type_name in types_tool.getTypeInfo(line_type_name).getTypeAllowedContentTypeList():\n
if cell_type_name in movement_type_list:\n
type_set[cell_type_name] = 1\n
\n
......
763
\ No newline at end of file
764
\ No newline at end of file
......@@ -95,7 +95,7 @@
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>python: \'Role Definition\' in portal.portal_types[\'Web Section\'].allowed_content_types</string> </value>
<value> <string>python: \'Role Definition\' in portal.portal_types[\'Web Section\'].getTypeAllowedContentTypeList()</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -95,7 +95,7 @@
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>python: \'Role Definition\' in portal.portal_types[\'Web Site\'].allowed_content_types</string> </value>
<value> <string>python: \'Role Definition\' in portal.portal_types[\'Web Site\'].getTypeAllowedContentTypeList()</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -78,7 +78,7 @@ def calculateStatistics():\n
documents_groups = {}\n
documents_owners = {}\n
documents_classifications = {}\n
document_content_types = portal_types[\'Document Module\'].allowed_content_types\n
document_content_types = portal_types[\'Document Module\'].getTypeAllowedContentTypeList()\n
all_documents = portal_catalog.searchResults(portal_type = document_content_types)\n
total_documents = portal_catalog.countResults(portal_type = document_content_types)[0][0]\n
total_documents_released = portal_catalog.countResults(portal_type = document_content_types,\n
......
866
\ No newline at end of file
867
\ No newline at end of file
......@@ -68,8 +68,9 @@ class TestNestedLineMixin(TestSaleInvoiceMixin):
def _allowInvoiceLineContentTypeInInvoiceLine(self):
invoice_line_type = self.portal.portal_types['Invoice Line']
if 'Invoice Line' not in invoice_line_type.allowed_content_types:
invoice_line_type.allowed_content_types += ('Invoice Line',)
content_type_set = set(invoice_line_type.getTypeAllowedContentTypeList())
content_type_set.add('Invoice Line')
invoice_line_type._setTypeAllowedContentTypeList(tuple(content_type_set))
def stepGetRelatedInvoiceFromPackingList(self, sequence, **kw):
packing_list = sequence.get('packing_list')
......
......@@ -74,11 +74,11 @@ class TestDomainTool(TestPredicateMixIn):
def createData(self):
# We have no place to put a Predicate, we will put it in a
# Organisation Module
portal = self.getPortal()
type_tool = self.getTypeTool()
module_type = type_tool['Organisation Module']
module_type.allowed_content_types += ('Mapped Value',)
organisation_module = self.getOrganisationModule()
module_type = organisation_module.getTypeInfo()
content_type_set = set(module_type.getTypeAllowedContentTypeList())
content_type_set.add('Mapped Value')
module_type._setTypeAllowedContentTypeList(tuple(content_type_set))
if organisation_module.hasContent('1'):
organisation_module.deleteContent('1')
predicate = organisation_module.newContent(id='1',portal_type='Mapped Value')
......
......@@ -37,7 +37,6 @@ class TestERP5Category(ERP5TypeTestCase):
# Different variables used for this test
run_all_test = 1
quiet = 1
portal_type = 'Organisation'
base_cat = 'abc'
base_cat2 = 'efg'
cat_list = [base_cat + '/1',base_cat + '/2']
......@@ -88,21 +87,21 @@ class TestERP5Category(ERP5TypeTestCase):
self.deep_cat2 = self.cat2['1']
# associate base categories on Organisation portal type
portal_type = self.getTypeTool()[self.portal_type]
portal_type._setTypeBaseCategoryList([self.base_cat, self.base_cat2])
type_info = self.getTypeTool().Organisation
type_info._setTypeBaseCategoryList([self.base_cat, self.base_cat2])
# Reset aq dynamic
_aq_reset()
organisation_module = self.getOrganisationModule()
if not organisation_module.has_key('1'):
organisation_module.newContent(id='1', portal_type=self.portal_type)
organisation_module.newContent(id='1', portal_type='Organisation')
self.organisation = organisation_module['1']
if not self.organisation.has_key('1'):
self.organisation.newContent(id='1', portal_type='Telephone')
self.telephone = self.organisation['1']
if not organisation_module.has_key('2'):
organisation_module.newContent(id='2', portal_type=self.portal_type)
organisation_module.newContent(id='2', portal_type='Organisation')
self.organisation2 = organisation_module['2']
if not self.organisation2.has_key('1'):
self.organisation2.newContent(id='1', portal_type='Telephone')
......@@ -129,14 +128,13 @@ class TestERP5Category(ERP5TypeTestCase):
# We have no place to put a Predicate, we will put it in the
# Organisation Module
portal = self.getPortal()
type_tool = self.getTypeTool()
module_type = type_tool['%s Module' % self.portal_type]
module_type.allowed_content_types += ('Mapped Value',)
module = self.getOrganisationModule()
if not module.has_key('predicate'):
module.newContent(id='predicate', portal_type='Mapped Value')
predicate = module['predicate']
module_type = organisation_module.getTypeInfo()
content_type_set = set(module_type.getTypeAllowedContentTypeList())
content_type_set.add('Mapped Value')
module_type._setTypeAllowedContentTypeList(tuple(content_type_set))
if not organisation_module.has_key('predicate'):
organisation_module.newContent(id='predicate', portal_type='Mapped Value')
predicate = organisation_module['predicate']
predicate.setCriterion('quantity', identity=None, min=None, max=None)
self.predicate = predicate
......
......@@ -63,7 +63,8 @@ class TestTemplate(ERP5TypeTestCase):
portal_preferences.deleteContent(list(portal_preferences.objectIds()))
transaction.commit()
self.tic()
self.portal.portal_types['Preference'].allowed_content_types = ('Foo', 'Knowledge Pad')
self.portal.portal_types.Preference._setTypeAllowedContentTypeList(
('Foo', 'Knowledge Pad'))
self.portal.foo_module.manage_role(role_to_manage='Author',
permissions=[Permissions.AddPortalContent,
Permissions.CopyOrMove,
......
......@@ -264,8 +264,8 @@ def getSearchDialog(self, REQUEST=None):
default_search_key=default_search_key)
# TODO always add SearchableText ?
allowed_content_types = types_tool.getTypeInfo(self).allowed_content_types
allowed_content_types = self.getTypeInfo().getTypeAllowedContentTypeList()
# remember which workflow we already displayed
workflow_dict = dict()
# possible workflow states
......
......@@ -405,9 +405,10 @@ class ManageModule:
, id = module_portal_type)
# getting portal_type access to be able to modify attributes
module_portal_type_value = portal_types[module_portal_type]
# set alowed content type
module_portal_type_value.allowed_content_types = (object_portal_type_id,)
module_portal_type_value.filter_content_types = 1
# set allowed content type
module_portal_type_value.edit(
type_allowed_content_type_list=(object_portal_type_id,),
type_filter_content_type=1)
# adding usefull actions (in our case the view action)
module_portal_type_value.newContent(portal_type='Action Information',
reference="view",
......
......@@ -39,7 +39,7 @@ def CMFBTreeFolder_allowedContentTypes(self):
if myType is not None:
allowed_types_to_check = []
if myType.filter_content_types:
for portal_type in myType.allowed_content_types:
for portal_type in myType.getTypeAllowedContentTypeList():
contentType = portal_types.getTypeInfo(portal_type)
if contentType is None:
raise AttributeError, "Portal type '%s' does not exist " \
......
......@@ -1244,15 +1244,15 @@ class TestConstraint(PropertySheetTestCase):
# this property suppose that we can add some Organisation inside
# Organisation, so we temporary patch the type information.
ti = self.getTypesTool().getTypeInfo(obj)
allowed_types = list(ti.allowed_content_types)
ti.allowed_content_types = allowed_types + ['Organisation']
allowed_types = ti.getTypeAllowedContentTypeList()
ti._setTypeAllowedContentTypeList(allowed_types + ['Organisation'])
try:
constraint.fixConsistency(obj)
self.assertEquals('foo', obj.getDefaultOrganisationTitle())
self.assertEquals('foo', obj.default_organisation.getTitle())
finally:
ti.allowed_content_types = tuple(allowed_types)
ti._setTypeAllowedContentTypeList(allowed_types)
def test_PropertyTypeValidityFixLocalPropertiesForCategories(self):
"""Tests PropertyTypeValidity can repairs categories when this property
is added on the class later.
......
......@@ -2449,10 +2449,10 @@ class TestPropertySheet:
'Test Add Permission Document')
# allow this type info in Person Module
container_type_info = self.portal.portal_types.getTypeInfo('Person Module')
container_type_info.allowed_content_types = tuple(
container_type_info.allowed_content_types) + (
'Test Add Permission Document', )
container_type_info = self.getTypesTool().getTypeInfo('Person Module')
container_type_info._setTypeAllowedContentTypeList(
container_type_info.getTypeAllowedContentTypeList()
+ ['Test Add Permission Document'])
# by default this is empty, which implictly means "Add portal content",
# the default permission
......
......@@ -123,25 +123,17 @@ class TestFolder(ERP5TypeTestCase, LogInterceptor):
obj = self.newContent()
self.assertEquals(obj.getId(), id_generator_id_list[expected_length])
def _setAllowedContentTypesForFolderType(self, allowed_content_types):
def _setAllowedContentTypesForFolderType(self, allowed_content_type_list):
"""Set allowed content types for Folder portal type."""
folder_ti = self.getTypesTool()['Folder']
folder_ti.allowed_content_types = allowed_content_types
folder_ti.filter_content_types = True
self.getTypesTool().Folder.edit(
type_allowed_content_type_list=allowed_content_type_list,
type_filter_content_type=True)
def _assertAllowedContentTypes(self, obj, expected_allowed_content_types):
"""Asserts that allowed content types for obj are exactly what we
have in expected_allowed_content_types."""
allowed_content_types_id_list = [x.getId() for
x in obj.allowedContentTypes()]
self.assertEquals(len(expected_allowed_content_types),
len(allowed_content_types_id_list),
'expected %s and actual %s have different length' % (
expected_allowed_content_types,
allowed_content_types_id_list
))
for portal_type_name in expected_allowed_content_types:
self.failUnless(portal_type_name in allowed_content_types_id_list)
self.assertEqual(sorted(expected_allowed_content_types),
sorted(x.getId() for x in obj.allowedContentTypes()))
def test_AllowedContentTypes(self):
type_list = ['Folder', 'Category', 'Base Category']
......
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