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


Python models.get_page_models函数代码示例

本文整理汇总了Python中wagtail.wagtailcore.models.get_page_models函数的典型用法代码示例。如果您正苦于以下问题:Python get_page_models函数的具体用法?Python get_page_models怎么用?Python get_page_models使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_page_models函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_is_creatable_not_inherited

 def test_is_creatable_not_inherited(self):
     """
     is_creatable should not be inherited in the normal manner, and should
     default to True unless set otherwise
     """
     self.assertTrue(MTIChildPage.is_creatable)
     self.assertIn(MTIChildPage, get_page_models())
开发者ID:serzans,项目名称:wagtail,代码行数:7,代码来源:test_page_model.py

示例2: get_form_types

def get_form_types():
    global _FORM_CONTENT_TYPES
    if _FORM_CONTENT_TYPES is None:
        form_models = [model for model in get_page_models() if issubclass(model, AbstractForm)]

        _FORM_CONTENT_TYPES = list(ContentType.objects.get_for_models(*form_models).values())
    return _FORM_CONTENT_TYPES
开发者ID:alexgleason,项目名称:wagtail,代码行数:7,代码来源:models.py

示例3: unregister_signal_handlers

def unregister_signal_handlers():
    Image = get_image_model()

    for model in get_page_models():
        page_published.disconnect(purge_page_from_cache, sender=model)
        page_unpublished.disconnect(purge_page_from_cache, sender=model)

    post_save.disconnect(purge_image_from_cache, sender=Image)
    post_delete.disconnect(purge_image_from_cache, sender=Image)
    post_save.disconnect(purge_document_from_cache, sender=Document)
    post_delete.disconnect(purge_document_from_cache, sender=Document)
开发者ID:jschneier,项目名称:wagtail,代码行数:11,代码来源:signal_handlers.py

示例4: _clear_edit_handler_cache

    def _clear_edit_handler_cache(self):
        """
        These tests generate new EditHandlers with different settings. The
        cached edit handlers should be cleared before and after each test run
        to ensure that no changes leak through to other tests.
        """
        from wagtail.tests.testapp.models import DefaultRichBlockFieldPage

        block_page_edit_handler = DefaultRichBlockFieldPage.get_edit_handler()
        if block_page_edit_handler._form_class:
            rich_text_block = block_page_edit_handler._form_class.base_fields['body'].block.child_blocks['rich_text']
            if hasattr(rich_text_block, 'field'):
                del rich_text_block.field

        for page_class in get_page_models():
            page_class.get_edit_handler.cache_clear()
开发者ID:chrxr,项目名称:wagtail,代码行数:16,代码来源:test_rich_text.py

示例5: get_form_class_check

def get_form_class_check(app_configs, **kwargs):
    from wagtail.wagtailadmin.forms import WagtailAdminPageForm
    from wagtail.wagtailcore.models import get_page_models

    errors = []

    for cls in get_page_models():
        edit_handler = cls.get_edit_handler()
        if not issubclass(edit_handler.get_form_class(cls), WagtailAdminPageForm):
            errors.append(Error(
                "{cls}.get_edit_handler().get_form_class({cls}) does not extend WagtailAdminPageForm".format(
                    cls=cls.__name__),
                hint="Ensure that the EditHandler for {cls} creates a subclass of WagtailAdminPageForm".format(
                    cls=cls.__name__),
                obj=cls,
                id='wagtailadmin.E002'))

    return errors
开发者ID:DimiC,项目名称:wagtail,代码行数:18,代码来源:checks.py

示例6: base_form_class_check

def base_form_class_check(app_configs, **kwargs):
    from wagtail.wagtailadmin.forms import WagtailAdminPageForm
    from wagtail.wagtailcore.models import get_page_models

    errors = []

    for cls in get_page_models():
        if not issubclass(cls.base_form_class, WagtailAdminPageForm):
            errors.append(Error(
                "{}.base_form_class does not extend WagtailAdminPageForm".format(
                    cls.__name__),
                hint="Ensure that {}.{} extends WagtailAdminPageForm".format(
                    cls.base_form_class.__module__,
                    cls.base_form_class.__name__),
                obj=cls,
                id='wagtailadmin.E001'))

    return errors
开发者ID:DimiC,项目名称:wagtail,代码行数:18,代码来源:checks.py

示例7: handle

    def handle(self, from_text, to_text, **options):
        for revision in PageRevision.objects.filter(content_json__contains=from_text):
            revision.content_json = revision.content_json.replace(from_text, to_text)
            revision.save(update_fields=['content_json'])

        for page_class in get_page_models():
            self.stdout.write("scanning %s" % page_class._meta.verbose_name)

            child_relation_names = [rel.get_accessor_name() for rel in get_all_child_relations(page_class)]

            # Find all pages of this exact type; exclude subclasses, as they will
            # appear in the get_page_models() list in their own right, and this
            # ensures that replacement happens only once
            for page in page_class.objects.exact_type(page_class):
                replace_in_model(page, from_text, to_text)
                for child_rel in child_relation_names:
                    for child in getattr(page, child_rel).all():
                        replace_in_model(child, from_text, to_text)
开发者ID:AdamBolfik,项目名称:wagtail,代码行数:18,代码来源:replace_text.py

示例8: post

    def post(self, request):
        form = ExternalLinksForm(request.POST)
        if not form.is_valid():
            return render(request, self.template_name, {
                'form': form
            })
        url = form.cleaned_data['url']
        pages = []

        for cls in get_page_models():
            pages += list(cls.objects.search(url))

        pages = self.remove_duplicates(pages)
        pages = sorted(pages, key=lambda k: k.title)

        contacts = list(
            Contact.objects.filter(body__contains=url).order_by('heading'))
        resources = sorted(list(
            Resource.objects.filter(link__contains=url)) + list(
            Resource.objects.filter(alternate_link__contains=url)),
            key=lambda k: k.title)
        reusable_texts = list(
            ReusableText.objects.filter(text__contains=url).order_by('title'))

        num_page_results = len(pages)
        num_snippet_results = len(contacts + resources + reusable_texts)

        return render(request, self.template_name, {
            'form': form,
            'pages': pages,
            'contacts': contacts,
            'resources': resources,
            'reusable_texts': reusable_texts,
            'num_page_results': num_page_results,
            'num_snippet_results': num_snippet_results,
        })
开发者ID:cfpb,项目名称:cfgov-refresh,代码行数:36,代码来源:views.py

示例9: test_abstract_pages

 def test_abstract_pages(self):
     """
     Abstract models should not be creatable
     """
     self.assertFalse(AbstractPage.is_creatable)
     self.assertNotIn(AbstractPage, get_page_models())
开发者ID:serzans,项目名称:wagtail,代码行数:6,代码来源:test_page_model.py

示例10: test_is_creatable_false

 def test_is_creatable_false(self):
     """Page types should be able to disable their creation"""
     self.assertFalse(MTIBasePage.is_creatable)
     # non-creatable pages should still appear in the get_page_models list
     self.assertIn(MTIBasePage, get_page_models())
开发者ID:serzans,项目名称:wagtail,代码行数:5,代码来源:test_page_model.py

示例11: test_is_creatable_default

 def test_is_creatable_default(self):
     """By default, pages should be creatable"""
     self.assertTrue(SimplePage.is_creatable)
     self.assertIn(SimplePage, get_page_models())
开发者ID:serzans,项目名称:wagtail,代码行数:4,代码来源:test_page_model.py


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