misc: do not migrate empty strings to python conditions (#22466)

This commit is contained in:
Frédéric Péters 2018-03-12 14:17:49 +01:00
parent fe2b701f7d
commit 392039216a
2 changed files with 12 additions and 3 deletions

View File

@ -1526,12 +1526,18 @@ class PageField(Field):
def migrate(self):
changed = super(PageField, self).migrate()
if isinstance(self.condition, basestring):
self.condition = {'type': 'python', 'value': self.condition}
if self.condition:
self.condition = {'type': 'python', 'value': self.condition}
else:
self.condition = {}
changed = True
for post_condition in self.post_conditions or []:
condition = post_condition.get('condition')
if isinstance(condition, basestring):
post_condition['condition'] = {'type': 'python', 'value': condition}
if condition:
post_condition['condition'] = {'type': 'python', 'value': condition}
else:
post_condition['condition'] = {}
changed = True
return changed

View File

@ -132,7 +132,10 @@ class JumpWorkflowStatusItem(WorkflowStatusJumpItem):
def migrate(self):
changed = super(JumpWorkflowStatusItem, self).migrate()
if isinstance(self.condition, basestring):
self.condition = {'type': 'python', 'value': self.condition}
if self.condition:
self.condition = {'type': 'python', 'value': self.condition}
else:
self.condition = {}
changed = True
return changed