• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python models.SimplePage类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: TestPageQueryInSite

class TestPageQueryInSite(TestCase):
    fixtures = ['test.json']

    def setUp(self):
        self.site_2_page = SimplePage(
            title="Site 2 page",
            slug="site_2_page",
            content="Hello",
        )
        Page.get_first_root_node().add_child(instance=self.site_2_page)
        self.site_2_subpage = SimplePage(
            title="Site 2 subpage",
            slug="site_2_subpage",
            content="Hello again",
        )
        self.site_2_page.add_child(instance=self.site_2_subpage)

        self.site_2 = Site.objects.create(
            hostname='example.com',
            port=8080,
            root_page=Page.objects.get(pk=self.site_2_page.pk),
            is_default_site=False
        )
        self.about_us_page = SimplePage.objects.get(url_path='/home/about-us/')

    def test_in_site(self):
        site_2_pages = SimplePage.objects.in_site(self.site_2)

        self.assertIn(self.site_2_page, site_2_pages)
        self.assertIn(self.site_2_subpage, site_2_pages)
        self.assertNotIn(self.about_us_page, site_2_pages)
开发者ID:BertrandBordage,项目名称:wagtail,代码行数:31,代码来源:test_page_queryset.py


示例2: test_allowed_parent_page_types

    def test_allowed_parent_page_types(self):
        # SimplePage does not define any restrictions on parent page types
        # SimplePage is a valid parent page of SimplePage
        self.assertIn(ContentType.objects.get_for_model(SimplePage), SimplePage.allowed_parent_page_types())
        # BusinessChild cannot be a parent of anything
        self.assertNotIn(ContentType.objects.get_for_model(BusinessChild), SimplePage.allowed_parent_page_types())

        # StandardIndex does not allow anything as a parent
        self.assertNotIn(ContentType.objects.get_for_model(SimplePage), StandardIndex.allowed_parent_page_types())
        self.assertNotIn(ContentType.objects.get_for_model(StandardIndex), StandardIndex.allowed_parent_page_types())

        # BusinessSubIndex only allows BusinessIndex as a parent
        self.assertNotIn(ContentType.objects.get_for_model(SimplePage), BusinessSubIndex.allowed_parent_page_types())
        self.assertIn(ContentType.objects.get_for_model(BusinessIndex), BusinessSubIndex.allowed_parent_page_types())
开发者ID:noodle-learns-programming,项目名称:wagtail,代码行数:14,代码来源:test_page_model.py


示例3: test_allowed_parent_page_models

    def test_allowed_parent_page_models(self):
        # SimplePage does not define any restrictions on parent page types
        # SimplePage is a valid parent page of SimplePage
        self.assertIn(SimplePage, SimplePage.allowed_parent_page_models())
        # BusinessChild cannot be a parent of anything
        self.assertNotIn(BusinessChild, SimplePage.allowed_parent_page_models())

        # BusinessNowherePage does not allow anything as a parent
        self.assertNotIn(SimplePage, BusinessNowherePage.allowed_parent_page_models())
        self.assertNotIn(StandardIndex, BusinessNowherePage.allowed_parent_page_models())

        # BusinessSubIndex only allows BusinessIndex as a parent
        self.assertNotIn(SimplePage, BusinessSubIndex.allowed_parent_page_models())
        self.assertIn(BusinessIndex, BusinessSubIndex.allowed_parent_page_models())
开发者ID:serzans,项目名称:wagtail,代码行数:14,代码来源:test_page_model.py


示例4: setUp

    def setUp(self):
        # Create a submitter
        submitter = get_user_model().objects.create_user(
            username='submitter',
            email='[email protected]',
            password='password',
        )

        # Find root page
        self.root_page = Page.objects.get(id=2)

        # Create a page
        self.page = SimplePage(
            title='Wagtail, the powerful CMS for modern websites',
            slug='wagtail',
            content='Fast, elegant, open source',
        )

        self.root_page.add_child(instance=self.page)

        # Submit it for moderation
        self.page.save_revision(user=submitter, submitted_for_moderation=True)

        # Create a revision
        self.revision = self.page.get_latest_revision()

        self.edit_page_url = reverse('wagtailadmin_pages:edit', args=(self.revision.page.id, ))
        self.preview_page_url = reverse('wagtailadmin_pages:preview_for_moderation', args=(self.revision.id, ))
开发者ID:BertrandBordage,项目名称:wagtail,代码行数:28,代码来源:test_moderation_list.py


示例5: setUp

    def setUp(self):
        self.root_page = Page.objects.get(id=2)

        # Add child page
        self.child_page = SimplePage(title="foobarbaz", content="hello")
        self.root_page.add_child(instance=self.child_page)

        self.login()
开发者ID:nealtodd,项目名称:wagtail,代码行数:8,代码来源:test_page_chooser.py


示例6: test_allowed_subpage_models

    def test_allowed_subpage_models(self):
        # SimplePage does not define any restrictions on subpage types
        # SimplePage is a valid subpage of SimplePage
        self.assertIn(SimplePage, SimplePage.allowed_subpage_models())
        # BusinessIndex is a valid subpage of SimplePage
        self.assertIn(BusinessIndex, SimplePage.allowed_subpage_models())
        # BusinessSubIndex is not valid, because it explicitly omits SimplePage from parent_page_types
        self.assertNotIn(BusinessSubIndex, SimplePage.allowed_subpage_models())

        # BusinessChild has an empty subpage_types list, so does not allow anything
        self.assertNotIn(SimplePage, BusinessChild.allowed_subpage_models())
        self.assertNotIn(BusinessIndex, BusinessChild.allowed_subpage_models())
        self.assertNotIn(BusinessSubIndex, BusinessChild.allowed_subpage_models())

        # BusinessSubIndex only allows BusinessChild as subpage type
        self.assertNotIn(SimplePage, BusinessSubIndex.allowed_subpage_models())
        self.assertIn(BusinessChild, BusinessSubIndex.allowed_subpage_models())
开发者ID:serzans,项目名称:wagtail,代码行数:17,代码来源:test_page_model.py


示例7: TestServeLatestDraftPage

class TestServeLatestDraftPage(TestCase):
    def setUp(self):
        self.default_site = Site.objects.get(is_default_site=True)
        self.page = SimplePage(title='live', slug='test', content='test')
        self.default_site.root_page.add_child(instance=self.page)
        self.page.title = 'draft'
        self.page.save_revision()

    @override_settings(SERVE_LATEST_DRAFT_PAGES=[])
    def test_not_serving_draft_serves_published_revision(self):
        response = self.client.get('/test/')
        self.assertContains(response, 'live')
        self.assertIsNone(response.get('Serving-Wagtail-Draft'))

    def test_serving_draft_serves_latest_revision_and_adds_header(self):
        with override_settings(SERVE_LATEST_DRAFT_PAGES=[self.page.pk]):
            response = self.client.get('/test/')
            self.assertContains(response, 'draft')
            self.assertEqual(response['Serving-Wagtail-Draft'], '1')
开发者ID:OrlandoSoto,项目名称:cfgov-refresh,代码行数:19,代码来源:test_wagtail_hooks.py


示例8: test_expired_pages_are_dropped_from_mod_queue

    def test_expired_pages_are_dropped_from_mod_queue(self):
        page = SimplePage(
            title="Hello world!",
            slug="hello-world",
            live=False,
            expire_at=timezone.now() - timedelta(days=1),
        )
        self.root_page.add_child(instance=page)

        page.save_revision(submitted_for_moderation=True)

        p = Page.objects.get(slug='hello-world')
        self.assertFalse(p.live)
        self.assertTrue(PageRevision.objects.filter(page=p, submitted_for_moderation=True).exists())

        management.call_command('publish_scheduled_pages')

        p = Page.objects.get(slug='hello-world')
        self.assertFalse(PageRevision.objects.filter(page=p, submitted_for_moderation=True).exists())
开发者ID:EricSchles,项目名称:wagtail,代码行数:19,代码来源:test_management_commands.py


示例9: test_future_go_live_page_will_not_be_published

    def test_future_go_live_page_will_not_be_published(self):
        page = SimplePage(
            title="Hello world!",
            slug="hello-world",
            live=False,
            go_live_at=timezone.now() + timedelta(days=1),
        )
        self.root_page.add_child(instance=page)

        page.save_revision(approved_go_live_at=timezone.now() - timedelta(days=1))

        p = Page.objects.get(slug='hello-world')
        self.assertFalse(p.live)
        self.assertTrue(PageRevision.objects.filter(page=p).exclude(approved_go_live_at__isnull=True).exists())

        management.call_command('publish_scheduled_pages')

        p = Page.objects.get(slug='hello-world')
        self.assertFalse(p.live)
        self.assertTrue(PageRevision.objects.filter(page=p).exclude(approved_go_live_at__isnull=True).exists())
开发者ID:EricSchles,项目名称:wagtail,代码行数:20,代码来源:test_management_commands.py


示例10: TestRevisionPreviewView

class TestRevisionPreviewView(TestCase, WagtailTestUtils):
    def setUp(self):
        # Login.
        self.user = self.login()

        # Find root page.
        self.root_page = Page.objects.get(id=2)

        # Add child page.
        self.child_page = SimplePage(
            title   = 'Test Page',
            slug    = 'test-page',
        )
        self.root_page.add_child(instance=self.child_page)

        # Create revisions.
        for i in range(20):
            self.child_page.save_revision(
                user                        = self.user,
                submitted_for_moderation    = False,
                approved_go_live_at         = None
            )

    def get_url(self):
        return reverse(
            'wagtailrollbacks:preview_page_version',
            args=(self.child_page.get_latest_revision().id,)
        )

    def get_get_permission_denied(self):
        self.client.logout()

        with self.assertRaises(PermissionDenied):
            self.client.get(self.get_url())

    def test_get(self):
        # Generate the response.
        response = self.client.get(self.get_url())

        self.assertEqual(response.status_code, 200)
        self.assertTemplateUsed(response, 'tests/simple_page.html')
开发者ID:adonm,项目名称:wagtailplus,代码行数:41,代码来源:test_views.py


示例11: test_allowed_parent_page_types

    def test_allowed_parent_page_types(self):
        """
        Same assertions as for test_allowed_parent_page_models -
        allowed_parent_page_types should mirror allowed_parent_page_models
        with ContentType objects rather than model classes
        """

        with self.ignore_deprecation_warnings():
            # SimplePage does not define any restrictions on parent page types
            # SimplePage is a valid parent page of SimplePage
            self.assertIn(get_ct(SimplePage), SimplePage.allowed_parent_page_types())
            # BusinessChild cannot be a parent of anything
            self.assertNotIn(get_ct(BusinessChild), SimplePage.allowed_parent_page_types())

            # BusinessNowherePage does not allow anything as a parent
            self.assertNotIn(get_ct(SimplePage), BusinessNowherePage.allowed_parent_page_types())
            self.assertNotIn(get_ct(StandardIndex), BusinessNowherePage.allowed_parent_page_types())

            # BusinessSubIndex only allows BusinessIndex as a parent
            self.assertNotIn(get_ct(SimplePage), BusinessSubIndex.allowed_parent_page_types())
            self.assertIn(get_ct(BusinessIndex), BusinessSubIndex.allowed_parent_page_types())
开发者ID:serzans,项目名称:wagtail,代码行数:21,代码来源:test_page_model.py


示例12: test_go_live_page_will_be_published

    def test_go_live_page_will_be_published(self):
        # Connect a mock signal handler to page_published signal
        signal_fired = [False]
        signal_page = [None]

        def page_published_handler(sender, instance, **kwargs):
            signal_fired[0] = True
            signal_page[0] = instance

        page_published.connect(page_published_handler)


        page = SimplePage(
            title="Hello world!",
            slug="hello-world",
            content="hello",
            live=False,
            has_unpublished_changes=True,
            go_live_at=timezone.now() - timedelta(days=1),
        )
        self.root_page.add_child(instance=page)

        page.save_revision(approved_go_live_at=timezone.now() - timedelta(days=1))

        p = Page.objects.get(slug='hello-world')
        self.assertFalse(p.live)
        self.assertTrue(PageRevision.objects.filter(page=p).exclude(approved_go_live_at__isnull=True).exists())

        management.call_command('publish_scheduled_pages')

        p = Page.objects.get(slug='hello-world')
        self.assertTrue(p.live)
        self.assertTrue(p.first_published_at)
        self.assertFalse(p.has_unpublished_changes)
        self.assertFalse(PageRevision.objects.filter(page=p).exclude(approved_go_live_at__isnull=True).exists())

        # Check that the page_published signal was fired
        self.assertTrue(signal_fired[0])
        self.assertEqual(signal_page[0], page)
        self.assertEqual(signal_page[0], signal_page[0].specific)
开发者ID:chrxr,项目名称:wagtail,代码行数:40,代码来源:test_management_commands.py


示例13: test_cache_clears_when_site_root_moves

    def test_cache_clears_when_site_root_moves(self):
        """
        This tests for an issue where if a site root page was moved, all
        the page urls in that site would change to None.

        The issue was caused by the 'wagtail_site_root_paths' cache
        variable not being cleared when a site root page was moved. Which
        left all the child pages thinking that they are no longer in the
        site and return None as their url.

        Fix: d6cce69a397d08d5ee81a8cbc1977ab2c9db2682
        Discussion: https://github.com/wagtail/wagtail/issues/7
        """
        # Get homepage, root page and site
        root_page = Page.objects.get(id=1)
        homepage = Page.objects.get(url_path='/home/')
        default_site = Site.objects.get(is_default_site=True)

        # Create a new homepage under current homepage
        new_homepage = SimplePage(title="New Homepage", slug="new-homepage", content="hello")
        homepage.add_child(instance=new_homepage)

        # Set new homepage as the site root page
        default_site.root_page = new_homepage
        default_site.save()

        # Warm up the cache by getting the url
        _ = homepage.url  # noqa

        # Move new homepage to root
        new_homepage.move(root_page, pos='last-child')

        # Get fresh instance of new_homepage
        new_homepage = Page.objects.get(id=new_homepage.id)

        # Check url
        self.assertEqual(new_homepage.url, '/')
开发者ID:Proper-Job,项目名称:wagtail,代码行数:37,代码来源:tests.py


示例14: test_allowed_subpage_types

    def test_allowed_subpage_types(self):
        """
        Same assertions as for test_allowed_subpage_models -
        allowed_subpage_types should mirror allowed_subpage_models with ContentType
        objects rather than model classes
        """

        with self.ignore_deprecation_warnings():
            # SimplePage does not define any restrictions on subpage types
            # SimplePage is a valid subpage of SimplePage
            self.assertIn(get_ct(SimplePage), SimplePage.allowed_subpage_types())
            # BusinessIndex is a valid subpage of SimplePage
            self.assertIn(get_ct(BusinessIndex), SimplePage.allowed_subpage_types())
            # BusinessSubIndex is not valid, because it explicitly omits SimplePage from parent_page_types
            self.assertNotIn(get_ct(BusinessSubIndex), SimplePage.allowed_subpage_types())

            # BusinessChild has an empty subpage_types list, so does not allow anything
            self.assertNotIn(get_ct(SimplePage), BusinessChild.allowed_subpage_types())
            self.assertNotIn(get_ct(BusinessIndex), BusinessChild.allowed_subpage_types())
            self.assertNotIn(get_ct(BusinessSubIndex), BusinessChild.allowed_subpage_types())

            # BusinessSubIndex only allows BusinessChild as subpage type
            self.assertNotIn(get_ct(SimplePage), BusinessSubIndex.allowed_subpage_types())
            self.assertIn(get_ct(BusinessChild), BusinessSubIndex.allowed_subpage_types())
开发者ID:serzans,项目名称:wagtail,代码行数:24,代码来源:test_page_model.py


示例15: test_can_exist_under

    def test_can_exist_under(self):
        self.assertTrue(SimplePage.can_exist_under(SimplePage()))

        # StandardIndex should only be allowed under a Page
        self.assertTrue(StandardIndex.can_exist_under(Page()))
        self.assertFalse(StandardIndex.can_exist_under(SimplePage()))

        # The Business pages are quite restrictive in their structure
        self.assertTrue(BusinessSubIndex.can_exist_under(BusinessIndex()))
        self.assertTrue(BusinessChild.can_exist_under(BusinessIndex()))
        self.assertTrue(BusinessChild.can_exist_under(BusinessSubIndex()))

        self.assertFalse(BusinessSubIndex.can_exist_under(SimplePage()))
        self.assertFalse(BusinessSubIndex.can_exist_under(BusinessSubIndex()))
        self.assertFalse(BusinessChild.can_exist_under(SimplePage()))
开发者ID:serzans,项目名称:wagtail,代码行数:15,代码来源:test_page_model.py


示例16: test_can_create_at

    def test_can_create_at(self):
        # Pages are not `is_creatable`, and should not be creatable
        self.assertFalse(Page.can_create_at(Page()))

        # SimplePage can be created under a simple page
        self.assertTrue(SimplePage.can_create_at(SimplePage()))

        # StandardIndex can be created under a Page, but not a SimplePage
        self.assertTrue(StandardIndex.can_create_at(Page()))
        self.assertFalse(StandardIndex.can_create_at(SimplePage()))

        # The Business pages are quite restrictive in their structure
        self.assertTrue(BusinessSubIndex.can_create_at(BusinessIndex()))
        self.assertTrue(BusinessChild.can_create_at(BusinessIndex()))
        self.assertTrue(BusinessChild.can_create_at(BusinessSubIndex()))

        self.assertFalse(BusinessChild.can_create_at(SimplePage()))
        self.assertFalse(BusinessSubIndex.can_create_at(SimplePage()))
开发者ID:serzans,项目名称:wagtail,代码行数:18,代码来源:test_page_model.py


示例17: setUp

    def setUp(self):
        self.site_2_page = SimplePage(
            title="Site 2 page",
            slug="site_2_page",
            content="Hello",
        )
        Page.get_first_root_node().add_child(instance=self.site_2_page)
        self.site_2_subpage = SimplePage(
            title="Site 2 subpage",
            slug="site_2_subpage",
            content="Hello again",
        )
        self.site_2_page.add_child(instance=self.site_2_subpage)

        self.site_2 = Site.objects.create(
            hostname='example.com',
            port=8080,
            root_page=Page.objects.get(pk=self.site_2_page.pk),
            is_default_site=False
        )
        self.about_us_page = SimplePage.objects.get(url_path='/home/about-us/')
开发者ID:BertrandBordage,项目名称:wagtail,代码行数:21,代码来源:test_page_queryset.py


示例18: setUp

    def setUp(self):
        # Login.
        self.user = self.login()

        # Find root page.
        self.root_page = Page.objects.get(id=2)

        # Add child page.
        self.child_page = SimplePage(
            title   = 'Test Page',
            slug    = 'test-page',
        )
        self.root_page.add_child(instance=self.child_page)

        # Create revisions.
        for i in range(20):
            self.child_page.save_revision(
                user                        = self.user,
                submitted_for_moderation    = False,
                approved_go_live_at         = None
            )
开发者ID:adonm,项目名称:wagtailplus,代码行数:21,代码来源:test_views.py


示例19: test_go_live_when_newer_revision_exists

    def test_go_live_when_newer_revision_exists(self):
        page = SimplePage(
            title="Hello world!",
            slug="hello-world",
            live=False,
            has_unpublished_changes=True,
            go_live_at=timezone.now() - timedelta(days=1),
        )
        self.root_page.add_child(instance=page)

        page.save_revision(approved_go_live_at=timezone.now() - timedelta(days=1))

        page.title = "Goodbye world!"
        page.save_revision(submitted_for_moderation=False)

        management.call_command('publish_scheduled_pages')

        p = Page.objects.get(slug='hello-world')
        self.assertTrue(p.live)
        self.assertTrue(p.has_unpublished_changes)
        self.assertEqual(p.title, "Hello world!")
开发者ID:EricSchles,项目名称:wagtail,代码行数:21,代码来源:test_management_commands.py


示例20: TestConfirmPageReversionView

class TestConfirmPageReversionView(TestCase, WagtailTestUtils):
    def setUp(self):
        # Login.
        self.user = self.login()

        # Find root page.
        self.root_page = Page.objects.get(id=2)

        # Add child page.
        self.child_page = SimplePage(
            title   = 'Test Page',
            slug    = 'test-page',
        )
        self.root_page.add_child(instance=self.child_page)

        # Create revisions.
        for i in range(20):
            self.child_page.save_revision(
                user                        = self.user,
                submitted_for_moderation    = False,
                approved_go_live_at         = None
            )

    def get_url(self):
        return reverse(
            'wagtailrollbacks:confirm_page_reversion',
            args=(self.child_page.get_latest_revision().id,)
        )

    def get_get_permission_denied(self):
        self.client.logout()

        with self.assertRaises(PermissionDenied):
            self.client.get(self.get_url())

    def test_page_is_locked(self):
        self.child_page.locked = True
        Page.objects.filter(pk=self.child_page.pk).update(locked=True)

        response = self.client.get(self.get_url())

        self.assertRedirects(
            response,
            reverse('wagtailadmin_pages:edit', args=(self.child_page.id,))
        )

    def test_get(self):
        response = self.client.get(self.get_url())

        self.assertTemplateUsed(
            response,
            'wagtailrollbacks/pages/confirm_reversion.html'
        )

    def test_post_draft(self):
        response = self.client.post(self.get_url(), {'fake': 'data'})

        self.assertRedirects(
            response,
            reverse('wagtailadmin_explore', args=(self.child_page.get_parent().id,))
        )

    def test_post_publish(self):
        post_data   = {'action-publish': True}
        response    = self.client.post(self.get_url(), post_data)

        self.assertRedirects(
            response,
            reverse('wagtailadmin_explore', args=(self.child_page.get_parent().id,))
        )

    def test_post_submit(self):
        post_data   = {'action-submit': True}
        response    = self.client.post(self.get_url(), post_data)

        self.assertRedirects(
            response,
            reverse('wagtailadmin_explore', args=(self.child_page.get_parent().id,))
        )
开发者ID:adonm,项目名称:wagtailplus,代码行数:79,代码来源:test_views.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python utils.login函数代码示例发布时间:2022-05-26
下一篇:
Python models.EventPageRelatedLink类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap