def get_or_create_buyers_guide(self): """ Return the first BuyersGuidePage, or create a new one. Will generate a Homepage if needed. """ buyersguide = BuyersGuidePage.objects.first() if not buyersguide: homepage = Homepage.objects.first() if not homepage: site_root = Page.objects.first() homepage = WagtailHomepageFactory.create( parent=site_root, title='Homepage', slug='homepage', hero_image__file__width=1080, hero_image__file__height=720) # Create the buyersguide page. buyersguide = BuyersGuidePage() buyersguide.title = 'Privacy not included' buyersguide.slug = 'privacynotincluded' buyersguide.slug_en = 'privacynotincluded' homepage = Homepage.objects.first() homepage.add_child(instance=buyersguide) buyersguide.save_revision().publish() self.homepage = Homepage.objects.first() return buyersguide
def setUp(self): self.factory = RequestFactory() self.user = User.objects.create_user(username='******', email='*****@*****.**', password='******') buyersguide = BuyersGuidePage.objects.first() if not buyersguide: homepage = Homepage.objects.first() if not homepage: site_root = Page.objects.first() homepage = WagtailHomepageFactory.create( parent=site_root, title='Homepage', slug='homepage', hero_image__file__width=1080, hero_image__file__height=720) # Create the buyersguide page. buyersguide = BuyersGuidePage() buyersguide.title = 'Privacy not included' buyersguide.slug = 'privacynotincluded' homepage.add_child(instance=buyersguide) buyersguide.save_revision().publish()