def setUp(self): homepage = Page.objects.get(url_path="/home/") business_index = BusinessIndex( title="Public Business Index", draft_title="Public Business Index", ) homepage.add_child(instance=business_index) another_business_index = BusinessIndex( title="Another Business Index", draft_title="Another Business Index", ) homepage.add_child(instance=another_business_index) secret_business_index = BusinessIndex( title="Private Business Index", draft_title="Private Business Index", ) homepage.add_child(instance=secret_business_index) business_editors = Group.objects.create(name="Business editors") business_editors.permissions.add( Permission.objects.get(codename="access_admin")) GroupPagePermission.objects.create(group=business_editors, page=business_index, permission_type="add") GroupPagePermission.objects.create(group=business_editors, page=another_business_index, permission_type="add") user = self.create_user(username="******", password="******") user.groups.add(business_editors) # Login self.login(username="******", password="******")
def setUp(self): # Find root page self.root_page = Page.objects.get(id=2) # root # |- index_page (BusinessIndex) # | |- child_1 (BusinessChild) # | |- child_2 (BusinessChild) # | |- child_3 (BusinessChild) self.index_page = BusinessIndex(title="Simple", slug="simple") self.root_page.add_child(instance=self.index_page) self.child_1 = BusinessChild(title="Child 1 of BusinessIndex", slug="child-1") self.index_page.add_child(instance=self.child_1) self.child_2 = BusinessChild(title="Child 2 of BusinessIndex", slug="child-2") self.index_page.add_child(instance=self.child_2) self.child_3 = BusinessChild(title="Child 3 of BusinessIndex", slug="child-3") self.index_page.add_child(instance=self.child_3) # Login self.user = self.login()
def setUp(self): self.login() self.homepage = Page.objects.get(url_path="/home/") self.event_index = Page.objects.get(url_path="/home/events/") self.business_index = BusinessIndex(title="Business", live=True) self.homepage.add_child(instance=self.business_index) self.business_child = BusinessChild(title="Business Child", live=True) self.business_index.add_child(instance=self.business_child)
def test_one_parent_exists(self): # Create a BusinessIndex page that BusinessChild can exist under homepage = Page.objects.get(url_path="/home/") business_index = BusinessIndex(title="Business Index") homepage.add_child(instance=business_index) # When one possible parent page exists, redirect straight to the page create view response = self.client.get("/admin/tests/businesschild/create/") expected_path = "/admin/pages/add/tests/businesschild/%d/" % business_index.pk expected_next_path = "/admin/tests/businesschild/" self.assertRedirects( response, "%s?next=%s" % (expected_path, expected_next_path))