当前位置: 首页>>代码示例>>Python>>正文


Python blocks.StaticBlock方法代码示例

本文整理汇总了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") 
开发者ID:wagtail,项目名称:wagtail,代码行数:9,代码来源:test_blocks.py

示例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") 
开发者ID:wagtail,项目名称:wagtail,代码行数:12,代码来源:test_blocks.py

示例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.") 
开发者ID:wagtail,项目名称:wagtail,代码行数:11,代码来源:test_blocks.py

示例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.") 
开发者ID:wagtail,项目名称:wagtail,代码行数:10,代码来源:test_blocks.py

示例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") 
开发者ID:wagtail,项目名称:wagtail,代码行数:9,代码来源:test_blocks.py

示例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>') 
开发者ID:wagtail,项目名称:wagtail,代码行数:6,代码来源:test_blocks.py

示例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) 
开发者ID:wagtail,项目名称:wagtail,代码行数:6,代码来源:test_blocks.py

示例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) 
开发者ID:wagtail,项目名称:wagtail,代码行数:6,代码来源:test_blocks.py

示例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', (), {}) 
开发者ID:OpenTechFund,项目名称:hypha,代码行数:4,代码来源:blocks.py


注:本文中的wagtail.core.blocks.StaticBlock方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。