43 lines
1.1 KiB
Python
43 lines
1.1 KiB
Python
import logging
|
|
|
|
from django.db import models
|
|
from wagtail.admin.edit_handlers import FieldPanel, TabbedInterface, \
|
|
ObjectList
|
|
from wagtail.core.fields import RichTextField
|
|
from wagtail.core.models import Page
|
|
from wagtail.images.edit_handlers import ImageChooserPanel
|
|
|
|
from book.blocks import DEFAULT_RICH_TEXT_FEATURES
|
|
from book.models import Book
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
class Chapter(Page):
|
|
class Meta:
|
|
verbose_name = 'Kapitel'
|
|
verbose_name_plural = 'Kapitel'
|
|
|
|
book = models.ForeignKey(Book, blank=False, null=False, on_delete=models.CASCADE)
|
|
|
|
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()
|