0001-workflows-convert-paragraphs-into-newlines-for-plain.patch
tests/form_pages/test_all.py | ||
---|---|---|
26 | 26 |
from wcs.qommon.ident.password_accounts import PasswordAccount |
27 | 27 |
from wcs.qommon.misc import ConnectionError |
28 | 28 |
from wcs.qommon.substitution import CompatibilityNamesDict |
29 |
from wcs.qommon.template import Template |
|
29 | 30 |
from wcs.roles import logged_users_role |
30 | 31 |
from wcs.tracking_code import TrackingCode |
31 | 32 |
from wcs.wf.backoffice_fields import SetBackofficeFieldsWorkflowStatusItem |
... | ... | |
8904 | 8905 |
'<p>Here is the address: <a href="https://example.net" rel="nofollow">https://example.net</a></p>' |
8905 | 8906 |
in resp.text |
8906 | 8907 |
) |
8908 | ||
8909 |
# test paragraphs are converted to newlines in plain text view |
|
8910 |
resp.form['comment'] = '<p>hello</p><p>world</p>' |
|
8911 |
resp = resp.form.submit('button_x1') |
|
8912 |
formdata = formdef.data_class().select()[0] |
|
8913 |
pub.substitutions.feed(formdata) |
|
8914 |
context = pub.substitutions.get_context_variables(mode='lazy') |
|
8915 |
tmpl = Template('{{form_comment}}') |
|
8916 |
assert tmpl.render(context) == 'hello\n\nworld' |
wcs/workflows.py | ||
---|---|---|
2759 | 2759 |
self.varname = varname |
2760 | 2760 | |
2761 | 2761 |
def get_as_plain_text(self): |
2762 |
return html.unescape(strip_tags(self.comment)) |
|
2762 |
return html.unescape(strip_tags(self.comment.replace('</p><p>', '\n\n')))
|
|
2763 | 2763 | |
2764 | 2764 |
def view(self): |
2765 | 2765 |
return htmltext('<div class="comment">%s</div>' % self.comment) |
2766 |
- |