Projet

Général

Profil

0002-misc-remove-mail-templates-site-option-57260.patch

Lauréline Guérin, 24 septembre 2021 15:54

Télécharger (5,8 ko)

Voir les différences:

Subject: [PATCH 2/5] misc: remove mail-templates site option (#57260)

 tests/test_mail_templates.py | 31 +++++--------------------------
 wcs/admin/workflows.py       |  3 +--
 wcs/qommon/publisher.py      |  1 -
 wcs/workflows.py             |  8 ++------
 4 files changed, 8 insertions(+), 35 deletions(-)
tests/test_mail_templates.py
58 58
    return user1
59 59

  
60 60

  
61
@pytest.fixture
62
def mail_templates_option(pub):
63
    if not pub.site_options.has_section('options'):
64
        pub.site_options.add_section('options')
65
    pub.site_options.set('options', 'mail-templates', 'true')
66
    with open(os.path.join(pub.app_dir, 'site-options.cfg'), 'w') as fd:
67
        pub.site_options.write(fd)
68
    return pub
69

  
70

  
71 61
@pytest.fixture
72 62
def mail_template():
73 63
    MailTemplate.wipe()
......
78 68
    return mail_template
79 69

  
80 70

  
81
def test_mail_templates_disabled(pub, superuser):
82
    if not pub.site_options.has_section('options'):
83
        pub.site_options.add_section('options')
84
    pub.site_options.set('options', 'mail-templates', 'false')
85
    with open(os.path.join(pub.app_dir, 'site-options.cfg'), 'w') as fd:
86
        pub.site_options.write(fd)
87
    app = login(get_app(pub))
88
    resp = app.get('/backoffice/workflows/')
89
    assert 'Mail Templates' not in resp
90

  
91

  
92
def test_mail_templates_basics(pub, superuser, mail_templates_option):
71
def test_mail_templates_basics(pub, superuser):
93 72
    MailTemplate.wipe()
94 73

  
95 74
    app = login(get_app(pub))
......
143 122
    assert 'first mail template' in resp
144 123

  
145 124

  
146
def test_mail_template_in_use(pub, superuser, mail_templates_option):
125
def test_mail_template_in_use(pub, superuser):
147 126
    Workflow.wipe()
148 127
    MailTemplate.wipe()
149 128
    workflow = Workflow(name='test workflow')
......
177 156
    assert 'still used' in resp.text
178 157

  
179 158

  
180
def test_admin_workflow_edit(pub, superuser, mail_templates_option):
159
def test_admin_workflow_edit(pub, superuser):
181 160
    Workflow.wipe()
182 161
    MailTemplate.wipe()
183 162
    mail_template = MailTemplate(name='test mail template')
......
206 185
    assert workflow.possible_status[0].items[0].mail_template == 'test-mail-template'
207 186

  
208 187

  
209
def test_workflow_send_mail_template_with_sql(superuser, mail_templates_option, emails):
188
def test_workflow_send_mail_template_with_sql(superuser, emails):
210 189
    pub = create_temporary_pub(sql_mode=True)
211 190
    req = HTTPRequest(None, {'SCRIPT_NAME': '/', 'SERVER_NAME': 'example.net'})
212 191
    pub.set_app_dir(req)
......
261 240
    assert logged_error.summary == 'reference to invalid mail template test-mail-template in status Status1'
262 241

  
263 242

  
264
def test_workflow_send_mail_template_attachments(pub, superuser, mail_templates_option, emails):
243
def test_workflow_send_mail_template_attachments(pub, superuser, emails):
265 244
    Workflow.wipe()
266 245
    MailTemplate.wipe()
267 246

  
wcs/admin/workflows.py
1909 1909
        r += htmltext('<h2>%s</h2>') % _('Workflows')
1910 1910
        r += htmltext('<span class="actions">')
1911 1911
        if is_global_accessible():
1912
            if get_publisher().has_site_option('mail-templates'):
1913
                r += htmltext('<a href="mail-templates/">%s</a>') % _('Mail Templates')
1912
            r += htmltext('<a href="mail-templates/">%s</a>') % _('Mail Templates')
1914 1913
            r += htmltext('<a href="data-sources/">%s</a>') % _('Data sources')
1915 1914
            r += htmltext('<a href="categories/">%s</a>') % _('Categories')
1916 1915
        r += htmltext('<a href="import" rel="popup">%s</a>') % _('Import')
wcs/qommon/publisher.py
391 391
    def has_site_option(self, option):
392 392
        defaults = {
393 393
            'studio': True,
394
            'mail-templates': True,
395 394
            'external-workflow': True,
396 395
            'complex-data': True,
397 396
        }
wcs/workflows.py
2968 2968
        super().add_parameters_widgets(form, parameters, prefix=prefix, formdef=formdef, **kwargs)
2969 2969
        subject_body_attrs = {}
2970 2970
        if 'subject' in parameters or 'body' in parameters:
2971
            if get_publisher().has_site_option('mail-templates') and MailTemplate.count():
2971
            if MailTemplate.count():
2972 2972
                subject_body_attrs = {
2973 2973
                    'data-dynamic-display-value': '',
2974 2974
                    'data-dynamic-display-child-of': '%smail_template' % prefix,
......
2997 2997
                size=40,
2998 2998
                attrs=subject_body_attrs,
2999 2999
            )
3000
        if (
3001
            'mail_template' in parameters
3002
            and get_publisher().has_site_option('mail-templates')
3003
            and MailTemplate.count()
3004
        ):
3000
        if 'mail_template' in parameters and MailTemplate.count():
3005 3001
            form.add(
3006 3002
                SingleSelectWidget,
3007 3003
                '%smail_template' % prefix,
3008
-