skillbox/server/book/models/chapter.py

35 lines
796 B
Python

import logging
from wagtail.admin.edit_handlers import FieldPanel, TabbedInterface, \
ObjectList
from wagtail.core.models import Page
logger = logging.getLogger(__name__)
class Chapter(Page):
class Meta:
verbose_name = 'Kapitel'
verbose_name_plural = 'Kapitel'
content_panels = [
FieldPanel('title', classname="full title"),
]
settings_panels = [
FieldPanel('slug')
]
edit_handler = TabbedInterface([
ObjectList(content_panels, heading='Content'),
ObjectList(settings_panels, heading='Settings'),
])
template = 'generic_page.html'
parent_page_types = ['book.Module']
@classmethod
def get_module_chapters(cls, module):
return cls.objects.filter(id__in=module.get_child_ids()).live()