def test_page_multiple_roots(): # Make sure the default root pages are removed created by wagtail # migrations Page.get_root_nodes().delete() assert Page.get_root_nodes().count() == 0 wagtail_factories.PageFactory(parent=None) wagtail_factories.PageFactory(parent=None) wagtail_factories.PageFactory(parent=None) assert Page.get_root_nodes().count() == 3
def setUp(self): home_page = CaosHomePage(title='TestHomePage') root_page = Page.get_root_nodes()[0] root_page.add_child(instance=home_page) sites = Site.objects.get(id=1) sites.root_page = home_page sites.save()
def setUp(self): home_page = CaosHomePage(title='TestHomePage') root_page = Page.get_root_nodes()[0] root_page.add_child(instance=home_page) sites = Site.objects.get(id=1) sites.root_page = home_page sites.save()
def create_index_page(self, sitename): '''create_index_page''' root_page = Page.get_root_nodes()[0] index_page = JournalIndexPage(title="{} Index Page".format(sitename), intro="{} introduction".format(sitename)) root_page.add_child(instance=index_page) index_page.save_revision().publish() return index_page
def test_can_create_page(self): parent = Page.get_root_nodes()[0] # Assert that a RecruitmentPage can be made here, with this POST data self.assertCanCreate(parent, RecruitmentPage, { 'title': 'Apply now!', 'title_sv': 'Ansök nu!', 'slug': 'apply2', }, 'Recruitment pages can be created at the root')
def _update_wagtail_pages(self, journal, create=True): '''create/update associated JournalIndexPage and JournalAboutPage''' site = journal.organization.site current_root = Page.objects.get(id=site.root_page_id) index_page = current_root.specific # if site root is not a JournalIndexPage, then create one and set it as site root if not isinstance(index_page, JournalIndexPage): # get base root page and add JournalIndexPage as child root_page = Page.get_root_nodes()[0] index_page = JournalIndexPage( title="{} Index Page".format(journal.organization.name), intro="{} introduction".format(journal.organization.name)) root_page.add_child(instance=index_page) index_page.save_revision().publish() # now set the site root page id to point to new_index_page site.root_page_id = index_page.id site.save() # create/update JournalAboutPage journal_about_page = index_page.get_first_child() if not create: if journal_about_page and isinstance(journal_about_page.specific, JournalAboutPage): journal_about_page.specific.journal = journal journal_about_page.specific.save() else: journal_about_page = JournalAboutPage( title=journal.name, journal=journal, short_description='{} description'.format(journal.name), long_description='') index_page.add_child(instance=journal_about_page) journal_about_page.save_revision().publish() return journal_about_page
def handle_noargs(self, **options): for node in Page.get_root_nodes(): for lang in settings.LANGUAGES: self.set_subtree(node, '/', lang=lang[0])
def handle_noargs(self, **options): for node in Page.get_root_nodes(): self.set_subtree(node, '/')
def handle(self, *args, **options): for node in Page.get_root_nodes(): self.set_subtree(node)
def handle(self, **options): with use_language(mt_settings.DEFAULT_LANGUAGE): for node in Page.get_root_nodes(): self.set_subtree(node, None)