Projet

Général

Profil

0001-misc-always-include-custom-texts-in-a-div-9027.patch

Frédéric Péters, 19 novembre 2015 11:29

Télécharger (3,41 ko)

Voir les différences:

Subject: [PATCH] misc: always include custom texts in a <div> (#9027)

 tests/test_texts.py       | 12 ++++++------
 wcs/qommon/admin/texts.py |  6 +++---
 2 files changed, 9 insertions(+), 9 deletions(-)
tests/test_texts.py
27 27

  
28 28
def test_get_html_text_default():
29 29
    TextsDirectory.register('foo2', 'Foo', default='Foo...')
30
    assert TextsDirectory.get_html_text('foo2') == 'Foo...'
30
    assert TextsDirectory.get_html_text('foo2') == '<div class="text-foo2">Foo...</div>'
31 31

  
32 32
def test_get_html_text_set():
33 33
    TextsDirectory.register('foo3', 'Foo', default='Foo...')
34 34
    pub.cfg['texts'] = {'text-foo3': None}
35 35
    pub.write_cfg()
36
    assert TextsDirectory.get_html_text('foo3') == 'Foo...'
36
    assert TextsDirectory.get_html_text('foo3') == '<div class="text-foo3">Foo...</div>'
37 37
    pub.cfg['texts'] = {'text-foo3': 'Bar...'}
38 38
    pub.write_cfg()
39
    assert TextsDirectory.get_html_text('foo3') == '<p>Bar...</p>'
39
    assert TextsDirectory.get_html_text('foo3') == '<div class="text-foo3"><p>Bar...</p></div>'
40 40
    pub.cfg['texts'] = {'text-foo3': '<div>Bar...</div>'}
41 41
    pub.write_cfg()
42
    assert TextsDirectory.get_html_text('foo3') == '<div>Bar...</div>'
42
    assert TextsDirectory.get_html_text('foo3') == '<div class="text-foo3"><div>Bar...</div></div>'
43 43

  
44 44
def test_get_html_subst():
45 45
    # test for variable substitution
......
47 47
    pub.substitutions.feed(MockSubstitutionVariables())
48 48
    pub.cfg['texts'] = {'text-foo4': '[bar]'}
49 49
    pub.write_cfg()
50
    assert TextsDirectory.get_html_text('foo4') == '<p>Foobar</p>'
50
    assert TextsDirectory.get_html_text('foo4') == '<div class="text-foo4"><p>Foobar</p></div>'
51 51

  
52 52
    pub.cfg['texts'] = {'text-foo4': '[foo]'}
53 53
    pub.write_cfg()
54
    assert TextsDirectory.get_html_text('foo4') == '<p>1 &lt; 3</p>'
54
    assert TextsDirectory.get_html_text('foo4') == '<div class="text-foo4"><p>1 &lt; 3</p></div>'
wcs/qommon/admin/texts.py
64 64
            get_response().add_javascript_code('var LIVE_EDIT_TOOLTIP = "%s";\n' % \
65 65
                    _('Double click to edit the text'))
66 66
            get_response().add_css_include('../js/smoothness/jquery-ui-1.10.0.custom.min.css')
67
            return htmltext('<div class="block-edit-custom-text">'\
67
            return htmltext('<div class="block-edit-custom-text text-%s">'\
68 68
                            '<a class="edit-custom-text" href="%sbackoffice/settings/texts/%s">%s</a>'\
69 69
                            '<div class="block-custom-text">'\
70 70
                            '%s'\
71
                            '</div></div>' % (root_url, key, _('Edit This Text'), text))
72
        return htmltext(text)
71
                            '</div></div>' % (key, root_url, key, _('Edit This Text'), text))
72
        return htmltext('<div class="text-%s">%s</div>' % (key, text))
73 73
    get_html_text = classmethod(get_html_text)
74 74

  
75 75
    def register(cls, key, description, hint=None, default=None,
76
-