Skip to content

Commit

Permalink
Fix issue with creating child pages
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Vetter committed Aug 16, 2013
1 parent aea22c9 commit 29ea463
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions fancypages/dashboard/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ def clean_name(self):
def save(self, *args, **kwargs):
page_kwargs = copy(self.cleaned_data)
page_kwargs.pop('visibility_types')
if self.parent:
return self.parent.add_child(**page_kwargs)
return FancyPage.add_root(**page_kwargs)

class Meta:
Expand Down
15 changes: 15 additions & 0 deletions tests/functional/test_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,21 @@ def test_can_delete_a_child_page(self):
FancyPage.add_root(name="3rd page")
self.assertEquals(FancyPage.objects.count(), 3)

def test_can_create_child_page(self):
parent_page = FancyPage.add_root(name="A new page")
page = self.get(reverse("fp-dashboard:page-list"))

child_page_name = 'Test Page'
create_form = page.click("Add child page").form
create_form['name'] = child_page_name
list_page = create_form.submit()

self.assertRedirects(list_page, reverse('fp-dashboard:page-list'))

child_page = FancyPage.objects.get(name=child_page_name)
self.assertTrue(child_page.path.startswith(parent_page.path))
self.assertTrue(child_page.depth, 2)


class TestANewPage(test.FancyPagesWebTest):
is_staff = True
Expand Down

0 comments on commit 29ea463

Please sign in to comment.