本文整理汇总了Python中wagtail.core.blocks.StaticBlock方法的典型用法代码示例。如果您正苦于以下问题:Python blocks.StaticBlock方法的具体用法?Python blocks.StaticBlock怎么用?Python blocks.StaticBlock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wagtail.core.blocks
的用法示例。
在下文中一共展示了blocks.StaticBlock方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_render_form_with_constructor
# 需要导入模块: from wagtail.core import blocks [as 别名]
# 或者: from wagtail.core.blocks import StaticBlock [as 别名]
def test_render_form_with_constructor(self):
block = blocks.StaticBlock(
admin_text="Latest posts - This block doesn't need to be configured, it will be displayed automatically",
template='tests/blocks/posts_static_block.html')
rendered_html = block.render_form(None)
self.assertEqual(rendered_html, "Latest posts - This block doesn't need to be configured, it will be displayed automatically")
示例2: test_render_form_with_subclass
# 需要导入模块: from wagtail.core import blocks [as 别名]
# 或者: from wagtail.core.blocks import StaticBlock [as 别名]
def test_render_form_with_subclass(self):
class PostsStaticBlock(blocks.StaticBlock):
class Meta:
admin_text = "Latest posts - This block doesn't need to be configured, it will be displayed automatically"
template = "tests/blocks/posts_static_block.html"
block = PostsStaticBlock()
rendered_html = block.render_form(None)
self.assertEqual(rendered_html, "Latest posts - This block doesn't need to be configured, it will be displayed automatically")
示例3: test_render_form_with_subclass_displays_default_text_if_no_admin_text
# 需要导入模块: from wagtail.core import blocks [as 别名]
# 或者: from wagtail.core.blocks import StaticBlock [as 别名]
def test_render_form_with_subclass_displays_default_text_if_no_admin_text(self):
class LabelOnlyStaticBlock(blocks.StaticBlock):
class Meta:
label = "Latest posts"
block = LabelOnlyStaticBlock()
rendered_html = block.render_form(None)
self.assertEqual(rendered_html, "Latest posts: this block has no options.")
示例4: test_render_form_with_subclass_displays_default_text_if_no_admin_text_and_no_label
# 需要导入模块: from wagtail.core import blocks [as 别名]
# 或者: from wagtail.core.blocks import StaticBlock [as 别名]
def test_render_form_with_subclass_displays_default_text_if_no_admin_text_and_no_label(self):
class NoMetaStaticBlock(blocks.StaticBlock):
pass
block = NoMetaStaticBlock()
rendered_html = block.render_form(None)
self.assertEqual(rendered_html, "This block has no options.")
示例5: test_render_form_works_with_mark_safe
# 需要导入模块: from wagtail.core import blocks [as 别名]
# 或者: from wagtail.core.blocks import StaticBlock [as 别名]
def test_render_form_works_with_mark_safe(self):
block = blocks.StaticBlock(
admin_text=mark_safe("<b>Latest posts</b> - This block doesn't need to be configured, it will be displayed automatically"),
template='tests/blocks/posts_static_block.html')
rendered_html = block.render_form(None)
self.assertEqual(rendered_html, "<b>Latest posts</b> - This block doesn't need to be configured, it will be displayed automatically")
示例6: test_render
# 需要导入模块: from wagtail.core import blocks [as 别名]
# 或者: from wagtail.core.blocks import StaticBlock [as 别名]
def test_render(self):
block = blocks.StaticBlock(template='tests/blocks/posts_static_block.html')
result = block.render(None)
self.assertEqual(result, '<p>PostsStaticBlock template</p>')
示例7: test_serialize
# 需要导入模块: from wagtail.core import blocks [as 别名]
# 或者: from wagtail.core.blocks import StaticBlock [as 别名]
def test_serialize(self):
block = blocks.StaticBlock()
result = block.get_prep_value(None)
self.assertEqual(result, None)
示例8: test_deserialize
# 需要导入模块: from wagtail.core import blocks [as 别名]
# 或者: from wagtail.core.blocks import StaticBlock [as 别名]
def test_deserialize(self):
block = blocks.StaticBlock()
result = block.to_python(None)
self.assertEqual(result, None)
示例9: deconstruct
# 需要导入模块: from wagtail.core import blocks [as 别名]
# 或者: from wagtail.core.blocks import StaticBlock [as 别名]
def deconstruct(self):
return ('wagtail.core.blocks.static_block.StaticBlock', (), {})