misc: save empty conditions as None (#23855)

This commit is contained in:
Frédéric Péters 2018-05-16 09:46:32 +02:00
parent 7b0b2a35e6
commit a2fab65a14
2 changed files with 12 additions and 1 deletions

View File

@ -2276,6 +2276,16 @@ def test_workflows_edit_email_action(pub):
assert sendmail.attachments == ['form_var_upload_raw', 'form_var_upload2_raw',
'{"content":"foo", "filename":"bar.txt"}']
# check condition has been saved as None, not {}.
assert sendmail.condition is None
resp = app.get(item_url)
resp.form['condition$type'] = 'python'
resp.form['condition$value_python'] = 'True'
resp = resp.form.submit('submit')
sendmail = Workflow.get(workflow.id).get_status(st1.id).items[0]
assert sendmail.condition == {'type': 'python', 'value': 'True'}
def test_workflows_edit_jump_previous(pub):
create_superuser(pub)
role = create_role()

View File

@ -2321,10 +2321,11 @@ class ConditionWidget(CompositeWidget):
return {'data-validation-url': validation_url}
def _parse(self, request):
self.value = {}
self.value = None
if not self.get('type') or self.get('type') == 'none':
return
self.value = {}
self.value['type'] = self.get('type')
if self.value['type']: