當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。