Projet

Général

Profil

0001-misc-use-wysiwyg-widgets-for-comments-field-9839.patch

Frédéric Péters, 12 février 2016 09:11

Télécharger (2,71 ko)

Voir les différences:

Subject: [PATCH] misc: use wysiwyg widgets for comments field (#9839)

 tests/test_admin_pages.py | 31 +++++++++++++++++++++++++++++++
 wcs/fields.py             |  8 ++++++--
 2 files changed, 37 insertions(+), 2 deletions(-)
tests/test_admin_pages.py
957 957
            {'condition': 'foo2', 'error_message': 'bar2'},
958 958
    ]
959 959

  
960
def test_form_edit_comment_field(pub):
961
    create_superuser(pub)
962
    create_role()
963

  
964
    FormDef.wipe()
965
    formdef = FormDef()
966
    formdef.name = 'form title'
967
    formdef.fields = [fields.CommentField(id='1', label='a comment field', type='comment')]
968
    formdef.store()
969

  
970
    app = login(get_app(pub))
971
    resp = app.get('/backoffice/forms/1/fields/1/')
972
    assert 'a comment field' in resp.body
973
    assert 'WysiwygTextWidget' in resp.body
974

  
975
    # legacy, double line breaks will be converted to paragraphs
976
    formdef.fields = [fields.CommentField(id='1', type='comment',
977
        label='a comment field\n\na second line')]
978
    formdef.store()
979
    resp = app.get('/backoffice/forms/1/fields/1/')
980
    assert not 'WysiwygTextWidget' in resp.body
981

  
982
    # starting with a <
983
    formdef.fields = [fields.CommentField(id='1', type='comment',
984
        label='<strong>a comment field\n\na second line</strong>')]
985
    formdef.store()
986
    resp = app.get('/backoffice/forms/1/fields/1/')
987
    assert 'WysiwygTextWidget' in resp.body
988

  
989

  
990

  
960 991
def test_form_legacy_int_id(pub):
961 992
    create_superuser(pub)
962 993
    create_role()
wcs/fields.py
497 497
        pass
498 498

  
499 499
    def fill_admin_form(self, form):
500
        form.add(TextWidget, 'label', title = _('Label'), value = self.label,
501
                required = True, cols = 70, rows = 3, render_br = False)
500
        if self.label and not self.label.startswith('<') and '\n\n' in self.label:
501
            form.add(TextWidget, 'label', title=_('Label'), value=self.label,
502
                    required=True, cols=70, rows=3, render_br=False)
503
        else:
504
            form.add(WysiwygTextWidget, 'label', title=_('Label'), value=self.label,
505
                    required=True)
502 506
        form.add(StringWidget, 'extra_css_class', title = _('Extra classes for CSS styling'),
503 507
                value=self.extra_css_class, size=30, advanced=(not self.extra_css_class))
504 508

  
505
-