Commit ec0e62e6 authored by wenjie.zheng's avatar wenjie.zheng Committed by Sebastien Robin

ERP5Site.py: fix the id problem of migration; migrate Workflow Tool for fresh...

ERP5Site.py: fix the id problem of migration; migrate Workflow Tool for fresh installation of instance.
parent aefd02ee
...@@ -47,7 +47,6 @@ import transaction ...@@ -47,7 +47,6 @@ import transaction
from App.config import getConfiguration from App.config import getConfiguration
MARKER = [] MARKER = []
# Site Creation DTML # Site Creation DTML
manage_addERP5SiteFormDtml = Globals.HTMLFile('dtml/addERP5Site', globals()) manage_addERP5SiteFormDtml = Globals.HTMLFile('dtml/addERP5Site', globals())
...@@ -1639,21 +1638,26 @@ class ERP5Site(FolderMixIn, CMFSite, CacheCookieMixin): ...@@ -1639,21 +1638,26 @@ class ERP5Site(FolderMixIn, CMFSite, CacheCookieMixin):
for obj in tool.objectValues(): for obj in tool.objectValues():
obj.migrateToPortalTypeClass() obj.migrateToPortalTypeClass()
security.declareProtected(Permissions.ManagePortal,
'migrateToPortalWorkflowClass')
def migrateToPortalWorkflowClass(self): def migrateToPortalWorkflowClass(self):
""" manually called function to migrate dcworkflow to erp5workflow. """ migrate dcworkflow to erp5workflow.
only for the specific case of workflow migration. can only be executed after install bt erp5_workflow.
""" """
tool = self.portal_workflow tool = self.portal_workflow
object_id_list = tool.objectIds() if tool.getPortalType() != 'ERP5 Workflow Tool':
object_clipboard = tool.manage_copyObjects(object_id_list) template_tool = self.getPortalObject().portal_templates
new_tool = self.newContent(id='portal_workflow_new', portal_type='ERP5 Workflow Tool') if template_tool.getInstalledBusinessTemplate('erp5_workflow') is None:
new_tool.manage_pasteObjects(object_clipboard) url = getBootstrapBusinessTemplateUrl('erp5_workflow')
new_tool._chains_by_type = tool._chains_by_type template_tool.download(url).install()
self.manage_delObjects(['portal_workflow'])
self.manage_renameObject(new_tool.id, 'portal_workflow') object_id_list = tool.objectIds()
object_clipboard = tool.manage_copyObjects(object_id_list)
new_tool = self.newContent(id='portal_workflow_new', portal_type='ERP5 Workflow Tool')
new_tool.manage_pasteObjects(object_clipboard)
new_tool._chains_by_type = tool._chains_by_type
# backup old type workflow tool
self.manage_delObjects('portal_workflow')
self.manage_renameObject(new_tool.id, 'portal_workflow')
new_tool.id = 'portal_workflow'
Globals.InitializeClass(ERP5Site) Globals.InitializeClass(ERP5Site)
def getBootstrapDirectory(): def getBootstrapDirectory():
...@@ -1693,6 +1697,7 @@ class PortalGenerator: ...@@ -1693,6 +1697,7 @@ class PortalGenerator:
addCMFCoreTool('CMF Skins Tool', None) addCMFCoreTool('CMF Skins Tool', None)
addCMFCoreTool('CMF Undo Tool', None) addCMFCoreTool('CMF Undo Tool', None)
addCMFCoreTool('CMF URL Tool', None) addCMFCoreTool('CMF URL Tool', None)
addCMFCoreTool('CMF Workflow Tool', None)
addCMFDefaultTool = p.manage_addProduct['CMFDefault'].manage_addTool addCMFDefaultTool = p.manage_addProduct['CMFDefault'].manage_addTool
addCMFDefaultTool('Default Discussion Tool', None) addCMFDefaultTool('Default Discussion Tool', None)
...@@ -1898,7 +1903,6 @@ class ERP5Generator(PortalGenerator): ...@@ -1898,7 +1903,6 @@ class ERP5Generator(PortalGenerator):
addERP5Tool(p, 'portal_password', 'Password Tool') addERP5Tool(p, 'portal_password', 'Password Tool')
addERP5Tool(p, 'portal_introspections', 'Introspection Tool') addERP5Tool(p, 'portal_introspections', 'Introspection Tool')
addERP5Tool(p, 'portal_acknowledgements', 'Acknowledgement Tool') addERP5Tool(p, 'portal_acknowledgements', 'Acknowledgement Tool')
addERP5Tool(p, 'portal_workflow', 'ERP5 Workflow Tool')
# Add ERP5Type Tool # Add ERP5Type Tool
addERP5Tool(p, 'portal_caches', 'Cache Tool') addERP5Tool(p, 'portal_caches', 'Cache Tool')
...@@ -2169,7 +2173,6 @@ class ERP5Generator(PortalGenerator): ...@@ -2169,7 +2173,6 @@ class ERP5Generator(PortalGenerator):
def setup(self, p, create_userfolder, **kw): def setup(self, p, create_userfolder, **kw):
update = kw.get('update', 0) update = kw.get('update', 0)
if getattr(p, 'setDefaultSorting', None) is not None: if getattr(p, 'setDefaultSorting', None) is not None:
p.setDefaultSorting('id', 0) p.setDefaultSorting('id', 0)
...@@ -2204,7 +2207,8 @@ class ERP5Generator(PortalGenerator): ...@@ -2204,7 +2207,8 @@ class ERP5Generator(PortalGenerator):
# Make sure the cache is initialized # Make sure the cache is initialized
p.portal_caches.updateCache() p.portal_caches.updateCache()
# Migrate Workflow Tool at fresh installation
p.migrateToPortalWorkflowClass()
self.setupLastTools(p, **kw) self.setupLastTools(p, **kw)
# Make sure tools are cleanly indexed with a uid before creating children # Make sure tools are cleanly indexed with a uid before creating children
......
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