torchbox/wagtail — pull request #491 by timheap (2014-07-22 07:18:29+00:00)
Title: Implement `Page.parent_page_types`

Similar to `Page.subpage_types`, but restricts which pages can have a specific page type as a child. Useful for Blog posts being restricted to Blog list pages, or similar things. This interacts with the subpage_types in a logical manner: `Page.allowed_subpage_types()`, will return a list of pages which are in `subpage_types`, and where the parent page is in the child page types `parent_page_types`. Both of these lists default to the list of all page types, which keeps the current behaviour intact as expected.

Tests will be coming, extending the BusinessPage tests already in `wagtailadmin`.

An example usage:

```python
from wagtail.wagtailcore.models import Page

class HomePage(Page):
parent_page_types = [] # Nothing can have a homepage as a child

class ContentPage(Page):
pass # Nothing special, these can go anywhere

class BlogIndex(Page):
pass # Nothing special, these can go anywhere

class BlogPost(Page):
parent_page_types = ['BlogIndex'] # Only allowed to be in the blog
```