68 lines
1.7 KiB
Python
68 lines
1.7 KiB
Python
# -*- coding: utf-8 -*-
|
|
#
|
|
# Iterativ GmbH
|
|
# http://www.iterativ.ch/
|
|
#
|
|
# Copyright (c) 2018 Iterativ GmbH. All rights reserved.
|
|
#
|
|
# Created on 15.08.18
|
|
# @author: Ramon Wenger <ramon.wenger@iterativ.ch>
|
|
import logging
|
|
|
|
from django.db import models
|
|
|
|
from wagtail.admin.edit_handlers import FieldPanel, TabbedInterface, \
|
|
ObjectList
|
|
from wagtail.core.fields import StreamField
|
|
from wagtail.core.models import Page
|
|
from wagtail.images.blocks import ImageChooserBlock
|
|
|
|
from book.blocks import TextBlock, ModalTextBlock, StudentEntryBlock
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
class ContentBlock(Page):
|
|
class Meta:
|
|
verbose_name = 'Inhaltsblock'
|
|
verbose_name_plural = 'Inhaltsblöcke'
|
|
|
|
contents = StreamField([
|
|
('text', TextBlock(icon='doc-full')),
|
|
('modal_text', ModalTextBlock(icon='placeholder')),
|
|
('student_entry', StudentEntryBlock(icon='download')),
|
|
('image', ImageChooserBlock(icon='image')),
|
|
('task', TextBlock(icon='tick'))
|
|
])
|
|
|
|
type = models.CharField(
|
|
max_length=100,
|
|
choices=(
|
|
('plain', 'Normal'),
|
|
('yellow', 'Gelb'),
|
|
('green', 'Grün'),
|
|
('blue', 'Blau'),
|
|
)
|
|
)
|
|
|
|
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.Chapter']
|
|
|
|
@classmethod
|
|
def get_chapter_content_blocks(cls, chapter):
|
|
return cls.objects.filter(id__in=chapter.get_child_ids()).live()
|