workflows: hide custom from email action option behind a feature flag (#48805)

This commit is contained in:
Frédéric Péters 2021-10-20 19:22:01 +02:00
parent a2a7f073f8
commit 8bb6391359
2 changed files with 32 additions and 1 deletions

View File

@ -959,6 +959,31 @@ def test_workflows_edit_email_action(pub):
sendmail = Workflow.get(workflow.id).get_status(st1.id).items[0]
assert sendmail.condition == {'type': 'python', 'value': 'True'}
# check "custom_from" is not advertised
resp = app.get(item_url)
assert 'custom_from' not in resp.text
# check it's advertised if the appropriate site option is set
pub.site_options.set('options', 'include-sendmail-custom-from-option', 'true')
with open(os.path.join(pub.app_dir, 'site-options.cfg'), 'w') as fd:
pub.site_options.write(fd)
resp = app.get(item_url)
assert 'custom_from' in resp.text
resp.form['custom_from$value_text'] = 'test@localhost'
resp = resp.form.submit('submit')
sendmail = Workflow.get(workflow.id).get_status(st1.id).items[0]
assert sendmail.custom_from == 'test@localhost'
# keep option displayed if it has a value
pub.site_options.set('options', 'include-sendmail-custom-from-option', 'false')
with open(os.path.join(pub.app_dir, 'site-options.cfg'), 'w') as fd:
pub.site_options.write(fd)
resp = app.get(item_url)
assert 'custom_from' in resp.text
assert resp.form['custom_from$value_text'].value == 'test@localhost'
def test_workflows_edit_jump_previous(pub):
create_superuser(pub)

View File

@ -2968,7 +2968,13 @@ class SendmailWorkflowStatusItem(WorkflowStatusItem):
return _('not completed')
def get_parameters(self):
return ('to', 'mail_template', 'subject', 'body', 'attachments', 'custom_from', 'condition')
parameters = ('to', 'mail_template', 'subject', 'body', 'attachments', 'custom_from', 'condition')
if (
not get_publisher().has_site_option('include-sendmail-custom-from-option')
and not self.custom_from
):
parameters = tuple(x for x in parameters if x != 'custom_from')
return parameters
def add_parameters_widgets(self, form, parameters, prefix='', formdef=None, **kwargs):
super().add_parameters_widgets(form, parameters, prefix=prefix, formdef=formdef, **kwargs)