Commit d1be5248 authored by Jérome Perrin's avatar Jérome Perrin

Workflow: add a simple _checkConsistency implementation

For now only checks that error_message is missing, but later we might
extended this to perform more check on the workflow definition.
parent 0eca529a
......@@ -358,6 +358,9 @@ class InteractionWorkflow(Workflow):
def getStateValueList(self):
return []
def _checkConsistency(self, fixit=False):
return []
security.declareProtected(Permissions.AccessContentsInformation, 'showAsXML')
def showAsXML(self, root=None):
from lxml import etree
......
......@@ -30,6 +30,7 @@
## Used in Products.ERP5Type.patches.DCWorkflow so this needs to go first...
from Acquisition import aq_parent, aq_inner
from Products.PageTemplates.Expressions import SecureModuleImporter
from Products.ERP5Type.ConsistencyMessage import ConsistencyMessage
from AccessControl import getSecurityManager
from Products.PageTemplates.Expressions import getEngine
from six import reraise
......@@ -958,6 +959,26 @@ class Workflow(XMLObject):
raise ObjectMoved(ex.getNewObject(), res)
return res
def _checkConsistency(self, fixit=False):
"""Checks the workflow definition.
"""
consistency_message_list = []
# make sure we have necessary variables
variable_reference_set = {
v.getReference()
for v in self.contentValues(portal_type='Workflow Variable')
}
for variable_reference in 'error_message', :
if variable_reference not in variable_reference_set:
consistency_message_list.append(
ConsistencyMessage(
self,
object_relative_url=self.getRelativeUrl(),
message=
'Required variable {variable_reference} missing in workflow.'.
format(variable_reference=variable_reference)))
return consistency_message_list
security.declareProtected(Permissions.AccessContentsInformation, 'showAsXML')
def showAsXML(self, root=None):
from lxml import etree
......
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