kopia lustrzana https://github.com/wagtail/wagtail
rodzic
5f0fa624f9
commit
fa5deb6b44
|
@ -4,6 +4,7 @@ Changelog
|
|||
2.5 (xx.xx.xxxx) - IN DEVELOPMENT
|
||||
~~~~~~~~~~~~~~~~
|
||||
|
||||
* Added more informative error message when `|richtext` filter is applied to a non-string value (mukesh5)
|
||||
* Fix: Set `SERVER_PORT` to 443 in `Page.dummy_request()` for HTTPS sites (Sergey Fedoseev)
|
||||
* Fix: Validation error messages in `InlinePanel` no longer count towards `max_num` when disabling the 'add' button (Todd Dembrey, Thibaud Colas)
|
||||
|
||||
|
|
|
@ -337,6 +337,7 @@ Contributors
|
|||
* Nick Travis
|
||||
* Maylon Pedroso
|
||||
* Thijs Walcarius
|
||||
* mukesh5
|
||||
|
||||
Translators
|
||||
===========
|
||||
|
|
|
@ -14,6 +14,8 @@ What's new
|
|||
Other features
|
||||
~~~~~~~~~~~~~~
|
||||
|
||||
* Added more informative error message when ``|richtext`` filter is applied to a non-string value (mukesh5)
|
||||
|
||||
|
||||
Bug fixes
|
||||
~~~~~~~~~
|
||||
|
|
|
@ -87,7 +87,10 @@ def richtext(value):
|
|||
elif value is None:
|
||||
html = ''
|
||||
else:
|
||||
html = expand_db_html(value)
|
||||
if isinstance(value, str):
|
||||
html = expand_db_html(value)
|
||||
else:
|
||||
raise TypeError("'richtext' template filter received an invalid value; expected string, got {}.".format(type(value)))
|
||||
|
||||
return mark_safe('<div class="rich-text">' + html + '</div>')
|
||||
|
||||
|
|
|
@ -261,3 +261,11 @@ class TestRichtextTag(TestCase):
|
|||
def test_call_with_none(self):
|
||||
result = richtext(None)
|
||||
self.assertEqual(result, '<div class="rich-text"></div>')
|
||||
|
||||
def test_call_with_invalid_value(self):
|
||||
with self.assertRaisesRegex(TypeError, "'richtext' template filter received an invalid value"):
|
||||
richtext(42)
|
||||
|
||||
def test_call_with_bytes(self):
|
||||
with self.assertRaisesRegex(TypeError, "'richtext' template filter received an invalid value"):
|
||||
richtext(b"Hello world!")
|
||||
|
|
Ładowanie…
Reference in New Issue