Commit e73d2ed3 authored by Alexandre Boeglin's avatar Alexandre Boeglin

getFilteredRoleListFor uses RoleInformation.getRole() to get a dict

  representation of the role.
RoleInformation.getRole() uses the getBaseCategoryScript() accessor to get
  the script id. This accessor has been modified to return the default
  secutiry script if the user who configured the roles definitions did not
  specify a script.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@3827 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent c964d757
......@@ -40,7 +40,6 @@ from RoleInformation import ori
from zLOG import LOG
ERP5TYPE_SECURITY_GROUP_ID_GENERATION_SCRIPT = 'ERP5Type_asSecurityGroupId'
ERP5TYPE_SECURITY_CATEGORY_GENERATION_SCRIPT = 'ERP5Type_getSecurityCategoryFromAssignment'
class ERP5TypeInformation( FactoryTypeInformation, RoleProviderBase ):
"""
......@@ -224,12 +223,8 @@ class ERP5TypeInformation( FactoryTypeInformation, RoleProviderBase ):
# get the script and apply it if actual_base_category_list is not empty
if len(actual_base_category_list) > 0:
if definition['base_category_script']:
base_category_script_id = definition['base_category_script']
base_category_script = getattr(object, base_category_script_id, None)
else:
base_category_script_id = ERP5TYPE_SECURITY_CATEGORY_GENERATION_SCRIPT
base_category_script = getattr(object, base_category_script_id, None)
base_category_script_id = definition['base_category_script']
base_category_script = getattr(object, base_category_script_id, None)
if base_category_script is not None:
# call the script, which should return either a dict or a list of dicts
category_result = base_category_script(actual_base_category_list, user_name, object, object.getPortalType())
......
......@@ -28,6 +28,8 @@ from Permissions import ManagePortal
from types import StringType
ERP5TYPE_SECURITY_CATEGORY_GENERATION_SCRIPT = 'ERP5Type_getSecurityCategoryFromAssignment'
class RoleInformation( SimpleItem ):
""" Represent a single selectable role.
......@@ -132,7 +134,10 @@ class RoleInformation( SimpleItem ):
""" Return the base_category_script id
"""
return getattr(self, 'base_category_script', '')
base_category_script = getattr(self, 'base_category_script', '')
if base_category_script:
return base_category_script
return ERP5TYPE_SECURITY_CATEGORY_GENERATION_SCRIPT
security.declarePrivate( 'base_category' )
def clone( self ):
......
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