Commit 1a92b09f authored by Yoshinori Okuji's avatar Yoshinori Okuji

Allow Modules to propagate categories. Otherwise, it is too hard to pack...

Allow Modules to propagate categories. Otherwise, it is too hard to pack information on business applications into a business template.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@30718 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 1d694c9a
...@@ -2846,18 +2846,19 @@ class ModuleTemplateItem(BaseTemplateItem): ...@@ -2846,18 +2846,19 @@ class ModuleTemplateItem(BaseTemplateItem):
mapping['portal_type'] = module.getPortalType() mapping['portal_type'] = module.getPortalType()
permission_list = [] permission_list = []
mapping['permission_list'] = module.showPermissions() mapping['permission_list'] = module.showPermissions()
mapping['category_list'] = module.getCategoryList()
self._objects[module_id] = mapping self._objects[module_id] = mapping
# Function to generate XML Code Manually # Function to generate XML Code Manually
def generateXml(self, path=None): def generateXml(self, path=None):
dict = self._objects[path] mapping = self._objects[path]
xml_data = ['<module>'] xml_data = ['<module>']
keys = dict.keys() keys = mapping.keys()
for key in sorted(keys): for key in sorted(keys):
if key == 'permission_list': if key == 'permission_list':
# separe permission dict into xml # separe permission dict into xml
xml_data.append(' <%s>' % (key, )) xml_data.append(' <%s>' % (key, ))
permission_list = dict[key] permission_list = mapping[key]
for perm in permission_list: for perm in permission_list:
# the type of the permission defined if we use acquired or not # the type of the permission defined if we use acquired or not
if isinstance(perm[1], list): if isinstance(perm[1], list):
...@@ -2878,8 +2879,16 @@ class ModuleTemplateItem(BaseTemplateItem): ...@@ -2878,8 +2879,16 @@ class ModuleTemplateItem(BaseTemplateItem):
xml_data.append(' <role>%s</role>' % (role, )) xml_data.append(' <role>%s</role>' % (role, ))
xml_data.append(' </permission>') xml_data.append(' </permission>')
xml_data.append(' </%s>' % (key, )) xml_data.append(' </%s>' % (key, ))
elif key == 'category_list':
category_list = mapping[key]
if not category_list:
continue
xml_data.append(' <%s>' % (key, ))
for category in category_list:
xml_data.append(' <category>%s</category>' % (category, ))
xml_data.append(' </%s>' % (key, ))
else: else:
xml_data.append(' <%s>%s</%s>' % (key, dict[key], key)) xml_data.append(' <%s>%s</%s>' % (key, mapping[key], key))
xml_data.append('</module>') xml_data.append('</module>')
return '\n'.join(xml_data) return '\n'.join(xml_data)
...@@ -2926,6 +2935,8 @@ class ModuleTemplateItem(BaseTemplateItem): ...@@ -2926,6 +2935,8 @@ class ModuleTemplateItem(BaseTemplateItem):
role_list = permission_dict.get(name, ('Manager',)) role_list = permission_dict.get(name, ('Manager',))
acquire = isinstance(role_list, list) acquire = isinstance(role_list, list)
module.manage_permission(name, roles=role_list, acquire=acquire) module.manage_permission(name, roles=role_list, acquire=acquire)
if 'category_list' in mapping:
module.setCategoryList(mapping['category_list'])
def _importFile(self, file_name, file): def _importFile(self, file_name, file):
if not file_name.endswith('.xml'): if not file_name.endswith('.xml'):
...@@ -2962,6 +2973,20 @@ class ModuleTemplateItem(BaseTemplateItem): ...@@ -2962,6 +2973,20 @@ class ModuleTemplateItem(BaseTemplateItem):
else: else:
value = node_list[0].data value = node_list[0].data
mapping[key] = str(value) mapping[key] = str(value)
category_list = []
try:
elt = xml.getElementsByTagName('category_list')[0]
except IndexError:
pass
else:
category_element_list = elt.getElementsByTagName('category')
for category_element in category_element_list:
category_node = category_element.childNodes[0]
category = str(category_node.data)
category_list.append(category)
mapping['category_list'] = category_list
self._objects[file_name[:-4]] = mapping self._objects[file_name[:-4]] = mapping
def uninstall(self, context, **kw): def uninstall(self, context, **kw):
......
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