How to use the publish.models.Page.objects.get function in publish

To help you get started, we’ve selected a few publish examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github johnsensible / django-publish / publish / tests.py View on Github external
def test_publish_repeated(self):
            self.page1.publish()
            self.page2.publish()
            
            self.page1.slug='main'
            self.page1.save()

            self.failUnlessEqual('/main/', self.page1.get_absolute_url())
            
            page1 = Page.objects.get(id=self.page1.id)
            page2 = Page.objects.get(id=self.page2.id)
            self.failUnlessEqual('/page1/', page1.public.get_absolute_url())
            self.failUnlessEqual('/page1/page2/', page2.public.get_absolute_url())
            
            page1.publish()
            page1 = Page.objects.get(id=self.page1.id)
            page2 = Page.objects.get(id=self.page2.id)
            self.failUnlessEqual('/main/', page1.public.get_absolute_url())
            self.failUnlessEqual('/main/page2/', page2.public.get_absolute_url())
            
            page1.slug='elsewhere'
            page1.save()
            page1 = Page.objects.get(id=self.page1.id)
            page2 = Page.objects.get(id=self.page2.id)
            page2.slug='meanwhile'
            page2.save()
github johnsensible / django-publish / publish / tests.py View on Github external
# nothing published yet
            self.failUnlessEqual(5, Page.objects.draft().count())
            self.failUnlessEqual(0, Page.objects.published().count())

            # now publish (using same queryset, as this will have cached the instances)
            draft.publish()

            self.failUnlessEqual(5, Page.objects.draft().count())
            self.failUnlessEqual(5, Page.objects.published().count())

            # now actually check the public parent's are setup right
            page1 = Page.objects.get(id=self.page1.id)
            page2 = Page.objects.get(id=self.page2.id)
            child1 = Page.objects.get(id=self.child1.id)
            child2 = Page.objects.get(id=self.child2.id)
            child3 = Page.objects.get(id=self.child3.id)

            self.failUnlessEqual(None, page1.public.parent)
            self.failUnlessEqual(None, page2.public.parent)
            self.failUnlessEqual(page1.public, child1.public.parent)
            self.failUnlessEqual(page1.public, child2.public.parent)
            self.failUnlessEqual(page2.public, child3.public.parent)
github johnsensible / django-publish / publish / tests.py View on Github external
# nothing published yet
            self.failUnlessEqual(5, Page.objects.draft().count())
            self.failUnlessEqual(0, Page.objects.published().count())

            # now publish (using same queryset, as this will have cached the instances)
            draft.publish()

            self.failUnlessEqual(5, Page.objects.draft().count())
            self.failUnlessEqual(5, Page.objects.published().count())

            # now actually check the public parent's are setup right
            page1 = Page.objects.get(id=self.page1.id)
            page2 = Page.objects.get(id=self.page2.id)
            child1 = Page.objects.get(id=self.child1.id)
            child2 = Page.objects.get(id=self.child2.id)
            child3 = Page.objects.get(id=self.child3.id)

            self.failUnlessEqual(None, page1.public.parent)
            self.failUnlessEqual(None, page2.public.parent)
            self.failUnlessEqual(page1.public, child1.public.parent)
            self.failUnlessEqual(page1.public, child2.public.parent)
            self.failUnlessEqual(page2.public, child3.public.parent)
github johnsensible / django-publish / publish / tests.py View on Github external
self.failUnlessEqual('/main/', self.page1.get_absolute_url())
            
            page1 = Page.objects.get(id=self.page1.id)
            page2 = Page.objects.get(id=self.page2.id)
            self.failUnlessEqual('/page1/', page1.public.get_absolute_url())
            self.failUnlessEqual('/page1/page2/', page2.public.get_absolute_url())
            
            page1.publish()
            page1 = Page.objects.get(id=self.page1.id)
            page2 = Page.objects.get(id=self.page2.id)
            self.failUnlessEqual('/main/', page1.public.get_absolute_url())
            self.failUnlessEqual('/main/page2/', page2.public.get_absolute_url())
            
            page1.slug='elsewhere'
            page1.save()
            page1 = Page.objects.get(id=self.page1.id)
            page2 = Page.objects.get(id=self.page2.id)
            page2.slug='meanwhile'
            page2.save()
            page2.publish()
            page1 = Page.objects.get(id=self.page1.id)
            page2 = Page.objects.get(id=self.page2.id)
            
            # only page2 should be published, not page1, as page1 already published
            self.failUnlessEqual(Publishable.PUBLISH_DEFAULT, page2.publish_state)
            self.failUnlessEqual(Publishable.PUBLISH_CHANGED, page1.publish_state)

            self.failUnlessEqual('/main/', page1.public.get_absolute_url())
            self.failUnlessEqual('/main/meanwhile/', page2.public.get_absolute_url())

            page1.publish()
            page1 = Page.objects.get(id=self.page1.id)
github johnsensible / django-publish / publish / tests.py View on Github external
self.failUnlessEqual('/page1/page2/', page2.public.get_absolute_url())
            
            page1.publish()
            page1 = Page.objects.get(id=self.page1.id)
            page2 = Page.objects.get(id=self.page2.id)
            self.failUnlessEqual('/main/', page1.public.get_absolute_url())
            self.failUnlessEqual('/main/page2/', page2.public.get_absolute_url())
            
            page1.slug='elsewhere'
            page1.save()
            page1 = Page.objects.get(id=self.page1.id)
            page2 = Page.objects.get(id=self.page2.id)
            page2.slug='meanwhile'
            page2.save()
            page2.publish()
            page1 = Page.objects.get(id=self.page1.id)
            page2 = Page.objects.get(id=self.page2.id)
            
            # only page2 should be published, not page1, as page1 already published
            self.failUnlessEqual(Publishable.PUBLISH_DEFAULT, page2.publish_state)
            self.failUnlessEqual(Publishable.PUBLISH_CHANGED, page1.publish_state)

            self.failUnlessEqual('/main/', page1.public.get_absolute_url())
            self.failUnlessEqual('/main/meanwhile/', page2.public.get_absolute_url())

            page1.publish()
            page1 = Page.objects.get(id=self.page1.id)
            page2 = Page.objects.get(id=self.page2.id)

            self.failUnlessEqual(Publishable.PUBLISH_DEFAULT, page2.publish_state)
            self.failUnlessEqual(Publishable.PUBLISH_DEFAULT, page1.publish_state)
github johnsensible / django-publish / publish / tests.py View on Github external
page2 = Page.objects.get(id=self.page2.id)
            page2.slug='meanwhile'
            page2.save()
            page2.publish()
            page1 = Page.objects.get(id=self.page1.id)
            page2 = Page.objects.get(id=self.page2.id)
            
            # only page2 should be published, not page1, as page1 already published
            self.failUnlessEqual(Publishable.PUBLISH_DEFAULT, page2.publish_state)
            self.failUnlessEqual(Publishable.PUBLISH_CHANGED, page1.publish_state)

            self.failUnlessEqual('/main/', page1.public.get_absolute_url())
            self.failUnlessEqual('/main/meanwhile/', page2.public.get_absolute_url())

            page1.publish()
            page1 = Page.objects.get(id=self.page1.id)
            page2 = Page.objects.get(id=self.page2.id)

            self.failUnlessEqual(Publishable.PUBLISH_DEFAULT, page2.publish_state)
            self.failUnlessEqual(Publishable.PUBLISH_DEFAULT, page1.publish_state)

            self.failUnlessEqual('/elsewhere/', page1.public.get_absolute_url())
            self.failUnlessEqual('/elsewhere/meanwhile/', page2.public.get_absolute_url())
github johnsensible / django-publish / publish / tests.py View on Github external
for p in draft:
                p.publish(dry_run=True, all_published=all_published)
            
            # nothing published yet
            self.failUnlessEqual(5, Page.objects.draft().count())
            self.failUnlessEqual(0, Page.objects.published().count())

            # now publish (using same queryset, as this will have cached the instances)
            draft.publish()

            self.failUnlessEqual(5, Page.objects.draft().count())
            self.failUnlessEqual(5, Page.objects.published().count())

            # now actually check the public parent's are setup right
            page1 = Page.objects.get(id=self.page1.id)
            page2 = Page.objects.get(id=self.page2.id)
            child1 = Page.objects.get(id=self.child1.id)
            child2 = Page.objects.get(id=self.child2.id)
            child3 = Page.objects.get(id=self.child3.id)

            self.failUnlessEqual(None, page1.public.parent)
            self.failUnlessEqual(None, page2.public.parent)
            self.failUnlessEqual(page1.public, child1.public.parent)
            self.failUnlessEqual(page1.public, child2.public.parent)
            self.failUnlessEqual(page2.public, child3.public.parent)
github johnsensible / django-publish / publish / tests.py View on Github external
page1 = Page.objects.get(id=self.page1.id)
            page2 = Page.objects.get(id=self.page2.id)
            self.failUnlessEqual('/page1/', page1.public.get_absolute_url())
            self.failUnlessEqual('/page1/page2/', page2.public.get_absolute_url())
            
            page1.publish()
            page1 = Page.objects.get(id=self.page1.id)
            page2 = Page.objects.get(id=self.page2.id)
            self.failUnlessEqual('/main/', page1.public.get_absolute_url())
            self.failUnlessEqual('/main/page2/', page2.public.get_absolute_url())
            
            page1.slug='elsewhere'
            page1.save()
            page1 = Page.objects.get(id=self.page1.id)
            page2 = Page.objects.get(id=self.page2.id)
            page2.slug='meanwhile'
            page2.save()
            page2.publish()
            page1 = Page.objects.get(id=self.page1.id)
            page2 = Page.objects.get(id=self.page2.id)
            
            # only page2 should be published, not page1, as page1 already published
            self.failUnlessEqual(Publishable.PUBLISH_DEFAULT, page2.publish_state)
            self.failUnlessEqual(Publishable.PUBLISH_CHANGED, page1.publish_state)

            self.failUnlessEqual('/main/', page1.public.get_absolute_url())
            self.failUnlessEqual('/main/meanwhile/', page2.public.get_absolute_url())

            page1.publish()
            page1 = Page.objects.get(id=self.page1.id)
            page2 = Page.objects.get(id=self.page2.id)