torchbox/wagtail — pull request #210 by ejucovy (2014-04-27 11:39:31+00:00)
Title: API for registering a custom page edit handler

For some page types I'd like to define custom admin interfaces with a different set of tabs, like "Main Content // Sidebar Content // Promote" instead of the default "Content // Promote."

I see that I can already do this by adding an entry to the `wagtailadmin.views.pages.PAGE_EDIT_HANDLERS` dictionary in my `models.py` at import time.

This PR proposes a `wagtailadmin.views.pages.register_page_edit_handler(page_class, handler)` function to formalize that approach. It would be used in a `models.py` like

MyPage.main_content_panels = [
FieldPanel("title"),
FieldPanel("main_section_content")
]
MyPage.promote_panels = MultiFieldPanel(COMMON_PANELS, "Common page configuration"),
MyPage.sidebar_panels = [
ImageChooserPanel("sidebar_image"),
InlinePanel(MyPage, "related_links", label="Related pages"),
]

from wagtail.wagtailadmin.views.pages import (register_page_edit_handler,
TabbedInterface,
ObjectList)
register_page_edit_handler(TabbedInterface([
ObjectList(MyPage.main_content_panels, heading="Main Content"),
ObjectList(MyPage.sidebar_panels, heading="Sidebar Content"),
ObjectList(MyPage.promote_panels, heading="Promote")])