Commit 6155e8c3 authored by Rafael Monnerat's avatar Rafael Monnerat

Initialize Workflow in a safer way, and do not permit use inconsistent Business Configurations.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@44416 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 9121fa4a
...@@ -91,6 +91,18 @@ class BusinessConfiguration(Item): ...@@ -91,6 +91,18 @@ class BusinessConfiguration(Item):
""" """
return self.getCurrentStateTitle() == END_STATE_TITLE return self.getCurrentStateTitle() == END_STATE_TITLE
security.declareProtected(Permissions.ModifyPortalContent, \
'initializeWorkflow')
def initializeWorkflow(self):
""" Initialize Related Workflow"""
workflow = self.getResourceValue()
if workflow is not None and \
(self.getResource() not in self.workflow_history):
if len(self.objectValues("ERP5 Configuration Save")) > 0:
raise ValueError("Business Configuration Cannot be initialized, \
it contains one or more Configurator Save")
workflow.initializeDocument(self)
security.declareProtected(Permissions.View, 'getNextTransition') security.declareProtected(Permissions.View, 'getNextTransition')
def getNextTransition(self): def getNextTransition(self):
""" Return next transition. """ """ Return next transition. """
...@@ -269,8 +281,7 @@ class BusinessConfiguration(Item): ...@@ -269,8 +281,7 @@ class BusinessConfiguration(Item):
next_state = self.unrestrictedTraverse(transition.getDestination()) next_state = self.unrestrictedTraverse(transition.getDestination())
workflow_history = current_state.getWorkflowHistory(self) workflow_history = current_state.getWorkflowHistory(self)
for wh in workflow_history: for wh in workflow_history:
wh_state = self.unrestrictedTraverse(wh['current_state']) if next_state == self.unrestrictedTraverse(wh['current_state']):
if wh_state == next_state:
configuration_save = self.unrestrictedTraverse(wh['configuration_save_url']) configuration_save = self.unrestrictedTraverse(wh['configuration_save_url'])
return configuration_save return configuration_save
......
...@@ -231,6 +231,8 @@ class ConfiguratorTool(BaseTool): ...@@ -231,6 +231,8 @@ class ConfiguratorTool(BaseTool):
validation_errors = None validation_errors = None
response = {} response = {}
business_configuration.initializeWorkflow()
## initial state no previous form to validate ## initial state no previous form to validate
if business_configuration.isInitialConfigurationState(): if business_configuration.isInitialConfigurationState():
need_validation = 0 need_validation = 0
......
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