2018-07-25 09:03:00 +01:00
|
|
|
from wagtail.core.fields import StreamField
|
|
|
|
from wagtail.core import blocks
|
|
|
|
from wagtail.images.blocks import ImageChooserBlock
|
|
|
|
from wagtail.documents.blocks import DocumentChooserBlock
|
|
|
|
from wagtail.embeds.blocks import EmbedBlock
|
|
|
|
from wagtailmarkdown.blocks import MarkdownBlock
|
|
|
|
|
2018-07-26 08:33:06 +01:00
|
|
|
HEADING_CHOICES = [('h' + str(i), 'H' + str(i)) for i in range(1, 6)]
|
|
|
|
|
|
|
|
|
|
|
|
class HeadingBlock(blocks.StructBlock):
|
|
|
|
size = blocks.ChoiceBlock(choices=HEADING_CHOICES)
|
|
|
|
value = blocks.CharBlock()
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
icon = 'title'
|
|
|
|
template = 'blocks/heading.html'
|
|
|
|
|
|
|
|
|
|
|
|
class VideoBlock(blocks.StructBlock):
|
|
|
|
video = EmbedBlock()
|
|
|
|
caption = blocks.CharBlock()
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
template = 'blocks/video.html'
|
|
|
|
|
|
|
|
|
2018-07-25 09:03:00 +01:00
|
|
|
def build_stream_field():
|
|
|
|
return StreamField([
|
|
|
|
('document', DocumentChooserBlock()),
|
2018-07-26 08:33:06 +01:00
|
|
|
('heading', HeadingBlock()),
|
2018-07-25 09:03:00 +01:00
|
|
|
('image', ImageChooserBlock()),
|
|
|
|
('markdown', MarkdownBlock()),
|
2018-07-26 08:33:06 +01:00
|
|
|
('ol', blocks.ListBlock(blocks.CharBlock(label="List Item"), icon="list-ol", label="Ordered List", template='blocks/ordered-list.html')),
|
2018-07-25 09:03:00 +01:00
|
|
|
('paragraph', blocks.RichTextBlock()),
|
|
|
|
('raw_html', blocks.RawHTMLBlock(label="Raw HTML")),
|
2018-07-26 08:33:06 +01:00
|
|
|
('ul', blocks.ListBlock(blocks.CharBlock(label="List Item"), icon="list-ul", label="Unordered List")),
|
|
|
|
('video', VideoBlock())
|
2018-07-27 21:37:11 +01:00
|
|
|
])
|