67 lines
1.8 KiB
Python
67 lines
1.8 KiB
Python
import logging
|
|
|
|
from django.db import models
|
|
from wagtail.admin.edit_handlers import FieldPanel, TabbedInterface, ObjectList, StreamFieldPanel
|
|
from wagtail.core.fields import StreamField
|
|
from wagtail.images.blocks import ImageChooserBlock
|
|
|
|
from book.blocks import TextBlock, BasicKnowledgeBlock, StudentEntryBlock, LinkBlock, VideoBlock
|
|
from core.wagtail_utils import StrictHierarchyPage
|
|
from user.models import UserGroup
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
class ContentBlock(StrictHierarchyPage):
|
|
class Meta:
|
|
verbose_name = 'Inhaltsblock'
|
|
verbose_name_plural = 'Inhaltsblöcke'
|
|
|
|
PLAIN = 'plain'
|
|
YELLOW = 'yellow'
|
|
GREEN = 'green'
|
|
BLUE = 'blue'
|
|
|
|
TYPE_CHOICES = (
|
|
(PLAIN, 'Normal'),
|
|
(YELLOW, 'Gelb'),
|
|
(GREEN, 'Grün'),
|
|
(BLUE, 'Blau'),
|
|
)
|
|
|
|
contents = StreamField([
|
|
('text_block', TextBlock(icon='doc-full')),
|
|
('basic_knowledge', BasicKnowledgeBlock(icon='placeholder')),
|
|
('student_entry', StudentEntryBlock(icon='download')),
|
|
('image_block', ImageChooserBlock(icon='image')),
|
|
('link_block', LinkBlock(icon='link')),
|
|
('task', TextBlock(icon='tick')),
|
|
('video_block', VideoBlock(icon='media')),
|
|
], null=True, blank=True)
|
|
|
|
type = models.CharField(
|
|
max_length=100,
|
|
choices=TYPE_CHOICES,
|
|
default=PLAIN
|
|
)
|
|
|
|
content_panels = [
|
|
FieldPanel('title', classname="full title"),
|
|
FieldPanel('type'),
|
|
StreamFieldPanel('contents')
|
|
]
|
|
|
|
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']
|
|
subpage_types = []
|