Projet

Général

Profil

0001-workflows-hide-custom-from-email-action-option-behin.patch

Frédéric Péters, 20 octobre 2021 19:22

Télécharger (2,88 ko)

Voir les différences:

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

 tests/admin_pages/test_workflow.py | 25 +++++++++++++++++++++++++
 wcs/workflows.py                   |  8 +++++++-
 2 files changed, 32 insertions(+), 1 deletion(-)
tests/admin_pages/test_workflow.py
959 959
    sendmail = Workflow.get(workflow.id).get_status(st1.id).items[0]
960 960
    assert sendmail.condition == {'type': 'python', 'value': 'True'}
961 961

  
962
    # check "custom_from" is not advertised
963
    resp = app.get(item_url)
964
    assert 'custom_from' not in resp.text
965

  
966
    # check it's advertised if the appropriate site option is set
967
    pub.site_options.set('options', 'include-sendmail-custom-from-option', 'true')
968
    with open(os.path.join(pub.app_dir, 'site-options.cfg'), 'w') as fd:
969
        pub.site_options.write(fd)
970

  
971
    resp = app.get(item_url)
972
    assert 'custom_from' in resp.text
973
    resp.form['custom_from$value_text'] = 'test@localhost'
974
    resp = resp.form.submit('submit')
975
    sendmail = Workflow.get(workflow.id).get_status(st1.id).items[0]
976
    assert sendmail.custom_from == 'test@localhost'
977

  
978
    # keep option displayed if it has a value
979
    pub.site_options.set('options', 'include-sendmail-custom-from-option', 'false')
980
    with open(os.path.join(pub.app_dir, 'site-options.cfg'), 'w') as fd:
981
        pub.site_options.write(fd)
982

  
983
    resp = app.get(item_url)
984
    assert 'custom_from' in resp.text
985
    assert resp.form['custom_from$value_text'].value == 'test@localhost'
986

  
962 987

  
963 988
def test_workflows_edit_jump_previous(pub):
964 989
    create_superuser(pub)
wcs/workflows.py
2968 2968
            return _('not completed')
2969 2969

  
2970 2970
    def get_parameters(self):
2971
        return ('to', 'mail_template', 'subject', 'body', 'attachments', 'custom_from', 'condition')
2971
        parameters = ('to', 'mail_template', 'subject', 'body', 'attachments', 'custom_from', 'condition')
2972
        if (
2973
            not get_publisher().has_site_option('include-sendmail-custom-from-option')
2974
            and not self.custom_from
2975
        ):
2976
            parameters = tuple(x for x in parameters if x != 'custom_from')
2977
        return parameters
2972 2978

  
2973 2979
    def add_parameters_widgets(self, form, parameters, prefix='', formdef=None, **kwargs):
2974 2980
        super().add_parameters_widgets(form, parameters, prefix=prefix, formdef=formdef, **kwargs)
2975
-