0001-misc-use-wysiwyg-widgets-for-comments-field-9839.patch
tests/test_admin_pages.py | ||
---|---|---|
950 | 950 |
{'condition': 'foo2', 'error_message': 'bar2'}, |
951 | 951 |
] |
952 | 952 | |
953 |
def test_form_edit_comment_field(pub): |
|
954 |
create_superuser(pub) |
|
955 |
create_role() |
|
956 | ||
957 |
FormDef.wipe() |
|
958 |
formdef = FormDef() |
|
959 |
formdef.name = 'form title' |
|
960 |
formdef.fields = [fields.CommentField(id='1', label='a comment field', type='comment')] |
|
961 |
formdef.store() |
|
962 | ||
963 |
app = login(get_app(pub)) |
|
964 |
resp = app.get('/backoffice/forms/1/fields/1/') |
|
965 |
assert 'a comment field' in resp.body |
|
966 |
assert 'WysiwygTextWidget' in resp.body |
|
967 | ||
968 |
# legacy, double line breaks will be converted to paragraphs |
|
969 |
formdef.fields = [fields.CommentField(id='1', type='comment', |
|
970 |
label='a comment field\n\na second line')] |
|
971 |
formdef.store() |
|
972 |
resp = app.get('/backoffice/forms/1/fields/1/') |
|
973 |
assert not 'WysiwygTextWidget' in resp.body |
|
974 | ||
975 |
# starting with a < |
|
976 |
formdef.fields = [fields.CommentField(id='1', type='comment', |
|
977 |
label='<strong>a comment field\n\na second line</strong>')] |
|
978 |
formdef.store() |
|
979 |
resp = app.get('/backoffice/forms/1/fields/1/') |
|
980 |
assert 'WysiwygTextWidget' in resp.body |
|
981 | ||
982 | ||
983 | ||
953 | 984 |
def test_form_legacy_int_id(pub): |
954 | 985 |
create_superuser(pub) |
955 | 986 |
create_role() |
wcs/fields.py | ||
---|---|---|
501 | 501 |
pass |
502 | 502 | |
503 | 503 |
def fill_admin_form(self, form): |
504 |
form.add(TextWidget, 'label', title = _('Label'), value = self.label, |
|
505 |
required = True, cols = 70, rows = 3, render_br = False) |
|
504 |
if self.label and (not self.label.startswith('<') and ( |
|
505 |
'\n\n' in self.label or '[end]' in self.label)): |
|
506 |
form.add(TextWidget, 'label', title=_('Label'), value=self.label, |
|
507 |
required=True, cols=70, rows=3, render_br=False) |
|
508 |
else: |
|
509 |
form.add(WysiwygTextWidget, 'label', title=_('Label'), value=self.label, |
|
510 |
required=True) |
|
506 | 511 |
form.add(StringWidget, 'extra_css_class', title = _('Extra classes for CSS styling'), |
507 | 512 |
value=self.extra_css_class, size=30, advanced=(not self.extra_css_class)) |
508 | 513 | |
509 |
- |