Commit 2f1297da authored by Xiaowu Zhang's avatar Xiaowu Zhang

ERP5Configurator: add check consistency command just to checkconsistency instead of fix

parent 2773e300
......@@ -39,6 +39,7 @@ from Products.ERP5.Document.Item import Item
INITIAL_STATE_TITLE = 'Start'
DOWNLOAD_STATE_TITLE = 'Download'
END_STATE_TITLE = 'End'
CHECK_CONSISTENCY_STATE_TITLE = 'Consistency'
class BusinessConfiguration(Item):
"""
......@@ -87,6 +88,12 @@ class BusinessConfiguration(Item):
"""
return self.getCurrentStateTitle() == END_STATE_TITLE
security.declareProtected(Permissions.View, 'isCheckConsistencyConfigurationState')
def isCheckConsistencyConfigurationState(self):
""" Check if the Business Configuration is on check consistency State
"""
return self.getCurrentStateTitle() == CHECK_CONSISTENCY_STATE_TITLE
security.declareProtected(Permissions.ModifyPortalContent, \
'initializeWorkflow')
def initializeWorkflow(self):
......@@ -166,6 +173,11 @@ class BusinessConfiguration(Item):
self._executeTransition()
transition = self.getNextTransition()
return None, None, None, None
elif self.isCheckConsistencyConfigurationState():
## exec next transition for this business configuration
self._executeTransition()
transition = self.getNextTransition()
return None, 'check consistency', None, None
if form_id is None:
## go on until you find a form
self._executeTransition()
......@@ -358,3 +370,32 @@ class BusinessConfiguration(Item):
if self.portal_workflow.isTransitionPossible(self, 'install'):
self.activate(after_tag=kw["tag"]).install()
############# Instance and Business Configuration ########################
security.declareProtected(Permissions.ModifyPortalContent, 'checkConsistency')
def checkConsistency(self):
"""
Build list of business templates according to already saved
Configuration Saves (i.e. user input).
This is the actual implementation which can be used from workflow
actions and Configurator requets
"""
kw = dict(tag="start_configuration_%s" % self.getId(),
after_method_id=["updateBusinessTemplateFromUrl",
"immediateReindexObject"])
# build
configuration_save_list = self.contentValues(portal_type='Configuration Save')
configuration_save_list.sort(lambda x, y: cmp(x.getIntIndex(x.getIntId()),
y.getIntIndex(y.getIntId())))
for configuration_save in configuration_save_list:
# XXX: check which items are configure-able
configuration_item_list = configuration_save.contentValues()
configuration_item_list.sort(lambda x, y: cmp(x.getIntId(), y.getIntId()))
for configurator_item in configuration_item_list:
configurator_item.activate(**kw).checkConsistency(
filter={"constraint_type":"configuration"})
kw["after_tag"] = kw["tag"]
kw["tag"] = "configurator_item_%s_%s" % (configurator_item.getId(),
configurator_item.getUid())
if self.portal_workflow.isTransitionPossible(self, 'install'):
self.activate(after_tag=kw["tag"]).install()
\ No newline at end of file
......@@ -137,6 +137,8 @@ class ConfiguratorTool(BaseTool):
next=response['next'])
elif response["command"] == "install":
return self.startInstallation(bc, REQUEST=REQUEST)
elif response["command"] == "check consistency":
return self.startCheckConsistency(bc, REQUEST=REQUEST)
def _next(self, business_configuration, kw):
""" Return next configuration form and validate previous. """
......@@ -266,6 +268,8 @@ class ConfiguratorTool(BaseTool):
if html is None:
## we have no more forms proceed to build
response.update(command="install", data=None)
elif html == 'check consistency':
response.update(command="check consistency", data=None)
else:
## we have more forms
next_state = self.restrictedTraverse(business_configuration.getNextTransition()\
......@@ -361,3 +365,20 @@ class ConfiguratorTool(BaseTool):
active_process=active_process, tag='initialERP5Setup'
).build()
return self.ConfiguratorTool_viewInstallationStatus(REQUEST)
def startCheckConsistency(self, business_configuration, REQUEST):
""" Start installation process as an activity which will
download/install bt5 template files and meanwhile offer
user a nice GUI to observe what's happening. """
global installation_status
# init installation status
installation_status['bt5']['all'] = 1
installation_status['bt5']['current'] = 0
installation_status['activity_list'] = []
active_process = self.portal_activities.newActiveProcess()
REQUEST.set('active_process_id', active_process.getId())
business_configuration.activate(
active_process=active_process, tag='initialERP5Setup'
).checkConsistency()
return self.ConfiguratorTool_viewInstallationStatus(REQUEST)
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