Fixed #629
This commit is contained in:
parent
a03422dcb7
commit
b0e5854833
@ -85,9 +85,14 @@ class CleanHtmlFormMixin(object):
|
|||||||
def clean(self):
|
def clean(self):
|
||||||
cleaned_data = super(CleanHtmlFormMixin, self).clean()
|
cleaned_data = super(CleanHtmlFormMixin, self).clean()
|
||||||
for field in self.get_clean_html_fields():
|
for field in self.get_clean_html_fields():
|
||||||
cleaned_data[field] = bleach.clean(cleaned_data[field],
|
try:
|
||||||
tags=HTML_TAG_WHITELIST,
|
cleaned_data[field] = bleach.clean(
|
||||||
attributes=HTML_ATTRIBUTES_WHITELIST,
|
cleaned_data[field],
|
||||||
styles=HTML_STYLES_WHITELIST,
|
tags=HTML_TAG_WHITELIST,
|
||||||
strip=True)
|
attributes=HTML_ATTRIBUTES_WHITELIST,
|
||||||
|
styles=HTML_STYLES_WHITELIST,
|
||||||
|
strip=True)
|
||||||
|
except KeyError:
|
||||||
|
# The field 'field' is not pressent. Do not change cleaned_data
|
||||||
|
pass
|
||||||
return cleaned_data
|
return cleaned_data
|
||||||
|
@ -127,6 +127,10 @@ class TestMotionCreateView(MotionViewTestCase):
|
|||||||
'identifier': 'foo'})
|
'identifier': 'foo'})
|
||||||
self.assertFormError(response, 'form', 'identifier', 'The Identifier is not unique.')
|
self.assertFormError(response, 'form', 'identifier', 'The Identifier is not unique.')
|
||||||
|
|
||||||
|
def test_empty_text_field(self):
|
||||||
|
response = self.admin_client.post(self.url, {'title': 'foo',
|
||||||
|
'submitter': self.admin})
|
||||||
|
self.assertFormError(response, 'form', 'text', 'This field is required.')
|
||||||
|
|
||||||
|
|
||||||
class TestMotionUpdateView(MotionViewTestCase):
|
class TestMotionUpdateView(MotionViewTestCase):
|
||||||
|
Loading…
Reference in New Issue
Block a user