本文整理汇总了Python中wagtail.admin.rich_text.HalloRichTextArea.value_from_datadict方法的典型用法代码示例。如果您正苦于以下问题:Python HalloRichTextArea.value_from_datadict方法的具体用法?Python HalloRichTextArea.value_from_datadict怎么用?Python HalloRichTextArea.value_from_datadict使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wagtail.admin.rich_text.HalloRichTextArea
的用法示例。
在下文中一共展示了HalloRichTextArea.value_from_datadict方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_embed_conversion_with_default_whitelist
# 需要导入模块: from wagtail.admin.rich_text import HalloRichTextArea [as 别名]
# 或者: from wagtail.admin.rich_text.HalloRichTextArea import value_from_datadict [as 别名]
def test_embed_conversion_with_default_whitelist(self):
widget = HalloRichTextArea()
result = widget.value_from_datadict({
'body': '<p>image <img src="foo" data-embedtype="image" data-id="123" data-format="left" data-alt="test alt" /> embed <span data-embedtype="media" data-url="https://www.youtube.com/watch?v=vwyuB8QKzBI">blah</span> badger <span data-embedtype="badger" data-colour="black-and-white">badger</span></p>'
}, {}, 'body')
self.assertHTMLEqual(result, '<p>image <embed embedtype="image" id="123" format="left" alt="test alt" /> embed <embed embedtype="media" url="https://www.youtube.com/watch?v=vwyuB8QKzBI" /> badger </p>')
示例2: test_embed_conversion_with_custom_whitelist
# 需要导入模块: from wagtail.admin.rich_text import HalloRichTextArea [as 别名]
# 或者: from wagtail.admin.rich_text.HalloRichTextArea import value_from_datadict [as 别名]
def test_embed_conversion_with_custom_whitelist(self):
widget = HalloRichTextArea(features=['h1', 'bold', 'image', 'somethingijustmadeup'])
result = widget.value_from_datadict({
'body': '<p>image <img src="foo" data-embedtype="image" data-id="123" data-format="left" data-alt="test alt" /> embed <span data-embedtype="media" data-url="https://www.youtube.com/watch?v=vwyuB8QKzBI">blah</span></p>'
}, {}, 'body')
self.assertHTMLEqual(result, '<p>image <embed embedtype="image" id="123" format="left" alt="test alt" /> embed </p>')
示例3: test_link_conversion_with_custom_whitelist
# 需要导入模块: from wagtail.admin.rich_text import HalloRichTextArea [as 别名]
# 或者: from wagtail.admin.rich_text.HalloRichTextArea import value_from_datadict [as 别名]
def test_link_conversion_with_custom_whitelist(self):
widget = HalloRichTextArea(features=['h1', 'bold', 'link', 'somethingijustmadeup'])
result = widget.value_from_datadict({
'body': '<p>a <a href="/foo" data-linktype="page" data-id="123">page</a>, <a href="/foo" data-linktype="squirrel" data-id="234">a squirrel</a> and a <a href="/foo" data-linktype="document" data-id="345">document</a></p>'
}, {}, 'body')
self.assertHTMLEqual(result, '<p>a <a linktype="page" id="123">page</a>, a squirrel and a document</p>')
示例4: test_link_conversion_with_default_whitelist
# 需要导入模块: from wagtail.admin.rich_text import HalloRichTextArea [as 别名]
# 或者: from wagtail.admin.rich_text.HalloRichTextArea import value_from_datadict [as 别名]
def test_link_conversion_with_default_whitelist(self):
widget = HalloRichTextArea()
result = widget.value_from_datadict({
'body': '<p>a <a href="/foo" data-linktype="page" data-id="123">page</a>, <a href="/foo" data-linktype="squirrel" data-id="234">a squirrel</a> and a <a href="/foo" data-linktype="document" data-id="345">document</a></p>'
}, {}, 'body')
self.assertHTMLEqual(result, '<p>a <a linktype="page" id="123">page</a>, a squirrel and a <a linktype="document" id="345">document</a></p>')
示例5: test_custom_whitelist
# 需要导入模块: from wagtail.admin.rich_text import HalloRichTextArea [as 别名]
# 或者: from wagtail.admin.rich_text.HalloRichTextArea import value_from_datadict [as 别名]
def test_custom_whitelist(self):
widget = HalloRichTextArea(features=['h1', 'bold', 'somethingijustmadeup'])
# accept elements that are represented in the feature list
result = widget.value_from_datadict({
'body': '<h1>h1</h1> <h2>h2</h2> <script>script</script> <p><b>bold</b> <i>italic</i></p> <blockquote>blockquote</blockquote>'
}, {}, 'body')
self.assertEqual(result, '<h1>h1</h1> h2 script <p><b>bold</b> italic</p> blockquote')
示例6: test_default_whitelist
# 需要导入模块: from wagtail.admin.rich_text import HalloRichTextArea [as 别名]
# 或者: from wagtail.admin.rich_text.HalloRichTextArea import value_from_datadict [as 别名]
def test_default_whitelist(self):
widget = HalloRichTextArea()
# when no feature list is specified, accept elements that are part of the default set
# (which includes h2)
result = widget.value_from_datadict({
'body': '<h2>heading</h2><script>script</script><blockquote>blockquote</blockquote>'
}, {}, 'body')
self.assertEqual(result, '<h2>heading</h2>scriptblockquote')