Projet

Général

Profil

0001-misc-don-t-reimport-theme-javascript-libraries-33449.patch

Frédéric Péters, 17 février 2020 20:53

Télécharger (3,19 ko)

Voir les différences:

Subject: [PATCH] misc: don't reimport theme javascript libraries (#33449)

 tests/test_form_pages.py    | 22 ++++++++++++++++++++++
 wcs/ctl/check_hobos.py      |  1 +
 wcs/qommon/http_response.py |  7 ++++++-
 3 files changed, 29 insertions(+), 1 deletion(-)
tests/test_form_pages.py
7665 7665
    pq = resp.pyquery.remove_namespaces()
7666 7666
    assert pq('.linked .status').text() == 'New'
7667 7667
    assert pq('.linked .foo_string').text() == 'zob'
7668

  
7669

  
7670
def test_js_libraries(pub):
7671
    create_formdef()
7672
    resp = get_app(pub).get('/test/', status=200)
7673
    assert 'jquery.js' not in resp.text
7674
    assert 'jquery.min.js' in resp.text
7675
    assert 'qommon.forms.js' in resp.text
7676

  
7677
    pub.cfg['debug'] = {'debug_mode': True}
7678
    pub.write_cfg()
7679
    resp = get_app(pub).get('/test/', status=200)
7680
    assert 'jquery.js' in resp.text
7681
    assert 'jquery.min.js' not in resp.text
7682
    assert 'qommon.forms.js' in resp.text
7683

  
7684
    pub.cfg['branding'] = {'included_js_libraries': ['jquery.js']}
7685
    pub.write_cfg()
7686
    resp = get_app(pub).get('/test/', status=200)
7687
    assert 'jquery.js' not in resp.text
7688
    assert 'jquery.min.js' not in resp.text
7689
    assert 'qommon.forms.js' in resp.text
wcs/ctl/check_hobos.py
188 188
                break
189 189
        if theme_data:
190 190
            pub.cfg['branding'] = {'theme': 'publik-base'}
191
            pub.cfg['branding']['included_js_libraries'] = theme_data['variables'].get('included_js_libraries')
191 192
            tenant_dir = pub.app_dir
192 193
            theme_dir = os.path.join(tenant_dir, 'theme')
193 194
            target_dir = os.path.join(self.THEMES_DIRECTORY, theme_data['module'])
wcs/qommon/http_response.py
66 66
            mappings['jquery.js'] = '../xstatic/jquery.js'
67 67
            mappings['jquery-ui.js'] = '../xstatic/jquery-ui.js'
68 68
            mappings['select2.js'] = 'select2/select2.js'
69
        branding_cfg = get_publisher().cfg.get('branding') or {}
70
        for included_js_library in branding_cfg.get('included_js_libraries') or []:
71
            mappings[included_js_library] = ''
69 72
        for script_name in script_names:
70
            mapped_script_name = mappings.get(script_name) or script_name
73
            mapped_script_name = mappings.get(script_name, script_name)
74
            if not mapped_script_name:
75
                continue
71 76
            if not mapped_script_name in self.javascript_scripts:
72 77
                if script_name == 'qommon.map.js':
73 78
                    self.add_javascript(['jquery.js'])
74
-