0001-forms-consider-rich-text-with-no-visible-element-as-.patch
tests/form_pages/test_all.py | ||
---|---|---|
8888 | 8888 |
assert '<p>hello evil</p>' in resp.text |
8889 | 8889 |
formdata = formdef.data_class().select()[0] |
8890 | 8890 |
assert formdata.evolution[-1].parts[-1].comment == '<p>hello evil</p>' |
8891 | ||
8892 |
resp.form['comment'] = '<p></p>' # left empty |
|
8893 |
resp = resp.form.submit('button_x1') |
|
8894 |
assert resp.pyquery('.error').text() == 'required field' |
wcs/qommon/form.py | ||
---|---|---|
50 | 50 |
import quixote.form.widget |
51 | 51 |
from django.conf import settings |
52 | 52 |
from django.utils.encoding import force_bytes, force_text |
53 |
from django.utils.html import strip_tags |
|
53 | 54 |
from django.utils.safestring import mark_safe |
54 | 55 |
from quixote import get_publisher, get_request, get_response, get_session |
55 | 56 |
from quixote.form import CheckboxWidget as QuixoteCheckboxWidget |
... | ... | |
2276 | 2277 |
self.value = self.value[6:] |
2277 | 2278 |
if self.value.endswith('<br />'): |
2278 | 2279 |
self.value = self.value[:-6] |
2280 |
if not strip_tags(self.value).strip(): |
|
2281 |
self.value = '' |
|
2282 | ||
2279 | 2283 |
# unescape Django template tags |
2280 | 2284 |
charset = get_publisher().site_charset |
2281 | 2285 | |
... | ... | |
2288 | 2292 |
self.validation_function(self.value) |
2289 | 2293 |
except ValueError as e: |
2290 | 2294 |
self.error = str(e) |
2295 |
if self.value == '': |
|
2296 |
self.value = None |
|
2291 | 2297 | |
2292 | 2298 |
def add_media(self): |
2293 | 2299 |
get_response().add_javascript(['qommon.wysiwyg.js']) |
2294 |
- |