Commit 41a577c1 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

export configured permissions only in ModuleTemplateItem.export() so as to get...

export configured permissions only in ModuleTemplateItem.export() so as to get smaller and stable XML output.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@30266 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent c473ea61
...@@ -2864,10 +2864,16 @@ class ModuleTemplateItem(BaseTemplateItem): ...@@ -2864,10 +2864,16 @@ class ModuleTemplateItem(BaseTemplateItem):
ptype = "list" ptype = "list"
else: else:
ptype = "tuple" ptype = "tuple"
xml_data += "\n <permission type='%s'>" %(ptype,)
xml_data += '\n <name>%s</name>' %(perm[0])
role_list = list(perm[1]) role_list = list(perm[1])
# Skip if permission is not configured (i.e. no role at all
# with acquire permission, or Manager only without acquire
# permission).
if (not len(role_list) and ptype == 'list') or \
(role_list == ['Manager'] and ptype == 'tuple'):
continue
role_list.sort() role_list.sort()
xml_data += "\n <permission type='%s'>" %(ptype,)
xml_data += '\n <name>%s</name>' %(perm[0])
for role in role_list: for role in role_list:
xml_data += '\n <role>%s</role>' %(role) xml_data += '\n <role>%s</role>' %(role)
xml_data += '\n </permission>' xml_data += '\n </permission>'
...@@ -2914,9 +2920,10 @@ class ModuleTemplateItem(BaseTemplateItem): ...@@ -2914,9 +2920,10 @@ class ModuleTemplateItem(BaseTemplateItem):
else: else:
module = portal.newContent(id=id, portal_type=str(mapping['portal_type'])) module = portal.newContent(id=id, portal_type=str(mapping['portal_type']))
module.setTitle(str(mapping['title'])) module.setTitle(str(mapping['title']))
for name, role_list in list(mapping['permission_list']): for name in valid_permissions.keys():
# By default, Manager only without acquire permission
role_list = dict(mapping['permission_list']).get(name, ('Manager',))
acquire = (type(role_list) == type([])) acquire = (type(role_list) == type([]))
if name in valid_permissions:
module.manage_permission(name, roles=role_list, acquire=acquire) module.manage_permission(name, roles=role_list, acquire=acquire)
def _importFile(self, file_name, file): def _importFile(self, file_name, file):
......
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