mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-04-18 05:51:13 +00:00
Merge branch 'tucarga-fix-richtext'
This commit is contained in:
commit
46e006dbd2
2 changed files with 19 additions and 1 deletions
|
|
@ -35,4 +35,9 @@ def wagtail_version():
|
|||
|
||||
@register.filter
|
||||
def richtext(value):
|
||||
return mark_safe('<div class="rich-text">' + expand_db_html(value) + '</div>')
|
||||
if value is not None:
|
||||
html = expand_db_html(value)
|
||||
else:
|
||||
html = ''
|
||||
|
||||
return mark_safe('<div class="rich-text">' + html + '</div>')
|
||||
|
|
|
|||
|
|
@ -2,8 +2,10 @@ import unittest
|
|||
|
||||
from django.test import TestCase
|
||||
from django.core.cache import cache
|
||||
from django.utils.safestring import SafeString
|
||||
|
||||
from wagtail.wagtailcore.models import Page, Site
|
||||
from wagtail.wagtailcore.templatetags.wagtailcore_tags import richtext
|
||||
from wagtail.wagtailcore.utils import resolve_model_string
|
||||
from wagtail.tests.models import SimplePage
|
||||
|
||||
|
|
@ -184,3 +186,14 @@ class TestResolveModelString(TestCase):
|
|||
@unittest.expectedFailure # Raising LookupError instead
|
||||
def test_resolve_from_bad_type(self):
|
||||
self.assertRaises(ValueError, resolve_model_string, resolve_model_string)
|
||||
|
||||
|
||||
class TestRichtextTag(TestCase):
|
||||
def test_call_with_text(self):
|
||||
result = richtext("Hello world!")
|
||||
self.assertEqual(result, '<div class="rich-text">Hello world!</div>')
|
||||
self.assertIsInstance(result, SafeString)
|
||||
|
||||
def test_call_with_none(self):
|
||||
result = richtext(None)
|
||||
self.assertEqual(result, '<div class="rich-text"></div>')
|
||||
|
|
|
|||
Loading…
Reference in a new issue