Commit 88e9c81e authored by Ivan Tyagov's avatar Ivan Tyagov

Local roles group use a category not a string value any more.

Remove not used proeprty.
parent 88d54087
......@@ -3047,7 +3047,7 @@ class PortalTypeRolesTemplateItem(BaseTemplateItem):
k = k[5:]
elif k == 'role_name':
k, v = 'id', '; '.join(v)
elif k not in ('title', 'description'):
elif k not in ('title', 'description', 'categories'):
k = {'id': 'object_id', # for stable sort
'role_base_category': 'base_category',
'role_base_category_script_id': 'base_category_script',
......@@ -3067,7 +3067,7 @@ class PortalTypeRolesTemplateItem(BaseTemplateItem):
xml_data += "\n <role id='%s'>" % role['id']
# uniq
for property in ('title', 'description', 'condition',
'base_category_script', 'local_roles_group_id'):
'base_category_script'):
prop_value = role.get(property)
if prop_value:
if isinstance(prop_value, str):
......@@ -3075,7 +3075,7 @@ class PortalTypeRolesTemplateItem(BaseTemplateItem):
xml_data += "\n <property id='%s'>%s</property>" % \
(property, prop_value)
# multi
for property in ('category', 'base_category'):
for property in ('categories', 'category', 'base_category'):
for prop_value in role.get(property, []):
if isinstance(prop_value, str):
prop_value = prop_value.decode('utf-8')
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Standard Property" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_local_properties</string> </key>
<value>
<tuple>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>mode</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>string</string> </value>
</item>
</dictionary>
</tuple>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>elementary_type/string</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>local_roles_group_id_property</string> </value>
</item>
<item>
<key> <string>mode</string> </key>
<value> <string>w</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Standard Property</string> </value>
</item>
<item>
<key> <string>property_default</string> </key>
<value> <string>python: \'\'</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -6537,6 +6537,11 @@ class TestBusinessTemplate(BusinessTemplateMixin):
' | security_uid',
'Alternate | alternate_security_uid',
)
# add category
self.portal.portal_categories.local_role_group.newContent(
portal_type='Category',
reference = 'Alternate',
id = 'Alternate')
types_tool = self.portal.portal_types
object_type = types_tool.newContent('Geek Object', 'Base Type',
......@@ -6558,7 +6563,7 @@ class TestBusinessTemplate(BusinessTemplateMixin):
self.tic()
object_type.newContent(portal_type='Role Information',
local_roles_group_id='Alternate',
local_role_group_value=self.portal.portal_categories.local_role_group.Alternate.getRelativeUrl(),
role_name_list=('Assignee', ))
bt = self.portal.portal_templates.newContent(
......@@ -6588,7 +6593,8 @@ class TestBusinessTemplate(BusinessTemplateMixin):
new_bt.install()
try:
role, = object_type.getRoleInformationList()
self.assertEquals('Alternate', role.getLocalRolesGroupId())
self.assertEquals(self.portal.portal_categories.local_role_group.Alternate,
role.getLocalRoleGroupValue())
path = self.portal.geek_module['1']
self.assertEquals([('group', ['Assignee'],)], [item for item in
path.__ac_local_roles__.items() if item[1] != ['Owner']])
......
......@@ -98,6 +98,12 @@ CREATE TABLE alternate_roles_and_users (
' | security_uid',
'Alternate | alternate_security_uid', )
# add category
self.portal.portal_categories.local_role_group.newContent(
portal_type='Category',
reference = 'Alternate',
id = 'Alternate')
# configure security on person, each user will be able to see his own
# person thanks to an Auditor role on "Alternate" local roles group id.
self.portal.portal_types.Person.newContent(
......@@ -105,7 +111,7 @@ CREATE TABLE alternate_roles_and_users (
role_name='Auditor',
role_base_category_script_id='ERP5Type_getSecurityCategoryFromSelf',
role_base_category='agent',
local_roles_group_id='Alternate')
local_role_group_value=self.portal.portal_categories.local_role_group.Alternate.getRelativeUrl())
self.portal.portal_caches.clearAllCache()
self.tic()
......
......@@ -574,9 +574,13 @@ class TestLocalRoleManagement(ERP5TypeTestCase):
def testLocalRolesGroupId(self):
"""Assigning a role with local roles group id.
"""
self.portal.portal_categories.local_role_group.newContent(
portal_type='Category',
reference = 'Alternate',
id = 'Alternate')
self._getTypeInfo().newContent(portal_type='Role Information',
role_name='Assignor',
local_roles_group_id='Alternate',
local_role_group_value=self.portal.portal_categories.local_role_group.Alternate.getRelativeUrl(),
role_category=self.defined_category)
self.loginAsUser(self.username)
......
......@@ -93,7 +93,14 @@ class LocalRoleAssignorMixIn(object):
local_roles_group_id_group_id = {}
# Merge results from applicable roles
for role_generator in self.getFilteredRoleListFor(ob):
local_roles_group_id = role_generator.getProperty('local_roles_group_id', '')
local_roles_group_id = ''
if getattr(role_generator, 'getLocalRoleGroupValue', None) is not None:
# only some role generators like 'Role Information' support it
local_role_group = role_generator.getLocalRoleGroupValue()
if local_role_group is not None:
# role definitions use category to classify different types of local roles
# so use their categories' reference
local_roles_group_id = local_role_group.getReference() or local_role_group.getId()
for group_id, role_list \
in role_generator.getLocalRolesFor(ob, user_name).iteritems():
group_id_role_dict.setdefault(group_id, set()).update(role_list)
......
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