本文整理汇总了Python中wagtail.wagtailcore.models.Page.allowed_subpage_models方法的典型用法代码示例。如果您正苦于以下问题:Python Page.allowed_subpage_models方法的具体用法?Python Page.allowed_subpage_models怎么用?Python Page.allowed_subpage_models使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wagtail.wagtailcore.models.Page
的用法示例。
在下文中一共展示了Page.allowed_subpage_models方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_page_models_have_search_fields
# 需要导入模块: from wagtail.wagtailcore.models import Page [as 别名]
# 或者: from wagtail.wagtailcore.models.Page import allowed_subpage_models [as 别名]
def test_page_models_have_search_fields(self):
"""
All page content types should have search_fields.
This doesn't tell us if we've set them correctly
but it ensures we've done something.
"""
# We get rid of the first element because it is a wagtailcore.Page
content_types = Page.allowed_subpage_models()[1:]
page_search_fields = Page.search_fields
base_page_search_fields = BasePage.search_fields
default_search_fields = set(page_search_fields + base_page_search_fields)
ignore = set(['AlertPage', 'AlertIndexPage', 'ConferenceIndexPage', 'FindingAidsPage', 'GroupMeetingMinutesIndexPage', \
'GroupReportsIndexPage', 'HomePage', 'IntranetFormPage', 'IntranetHomePage', 'IntranetUnitsReportsIndexPage', \
'ProjectIndexPage', 'GroupMeetingMinutesPage', 'GroupReportsPage', 'IntranetUnitsReportsPage'])
no_search_fields = set([])
for page_type in content_types:
if not len(set(page_type.search_fields)) > len(default_search_fields) and not page_type.__name__ in ignore:
no_search_fields.add(page_type.__name__)
self.assertEqual(len(no_search_fields), 0, 'The following content types don\'t have a search_fields declaration or their search_field declaration is not extending a base_class search_fields attribute: ' + str(no_search_fields))
示例2: test_page_models_have_subpage_types
# 需要导入模块: from wagtail.wagtailcore.models import Page [as 别名]
# 或者: from wagtail.wagtailcore.models.Page import allowed_subpage_models [as 别名]
def test_page_models_have_subpage_types(self):
"""
All page content types should have subpage_types
explicitly set. This test won't tell us if they're
set correctly but it will make sure we've at least
done something.
"""
# We get rid of the first element because it is a wagtailcore.Page
content_types = Page.allowed_subpage_models()[1:]
#number_of_content_types = len(content_types)
no_subpagetypes = set([])
for page_type in content_types:
#num = len(page_type.allowed_subpage_models())
try:
#self.assertNotEqual(num, number_of_content_types, 'This content type is missing a subpage_types declaration')
#assert page_type.subpage_types, 'This content type is missing a subpage_types declaration'
page_type.subpage_types
except:
no_subpagetypes.add(page_type.__name__)
self.assertEqual(len(no_subpagetypes), 0, 'The following content types don\'t have a subpages_type declaration: ' + str(no_subpagetypes))