Repository navigation
Expand file tree
/
Copy pathblocks.py
More file actions
67 lines (56 loc) · 1.85 KB
/
Copy pathblocks.py
File metadata and controls
67 lines (56 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
from wagtail.images.blocks import ImageChooserBlock
from wagtail.embeds.blocks import EmbedBlock
from wagtail.core.blocks import (
CharBlock, ChoiceBlock, RichTextBlock, StreamBlock, StructBlock, TextBlock,
)
class ImageBlock(StructBlock):
"""
Custom `StructBlock` for utilizing images with associated caption and
attribution data
"""
image = ImageChooserBlock(required=True)
caption = CharBlock(required=False)
attribution = CharBlock(required=False)
class Meta:
icon = 'image'
template = "blocks/image_block.html"
class HeadingBlock(StructBlock):
"""
Custom `StructBlock` that allows the user to select h2 - h4 sizes for headers
"""
heading_text = CharBlock(classname="title", required=True)
size = ChoiceBlock(choices=[
('', 'Select a header size'),
('h2', 'H2'),
('h3', 'H3'),
('h4', 'H4')
], blank=True, required=False)
class Meta:
icon = "title"
template = "blocks/heading_block.html"
class BlockQuote(StructBlock):
"""
Custom `StructBlock` that allows the user to attribute a quote to the author
"""
text = TextBlock()
attribute_name = CharBlock(
blank=True, required=False, label='e.g. Mary Berry')
class Meta:
icon = "fa-quote-left"
template = "blocks/blockquote.html"
# StreamBlocks
class BaseStreamBlock(StreamBlock):
"""
Define the custom blocks that `StreamField` will utilize
"""
heading_block = HeadingBlock()
paragraph_block = RichTextBlock(
icon="fa-paragraph",
template="blocks/paragraph_block.html"
)
image_block = ImageBlock()
block_quote = BlockQuote()
embed_block = EmbedBlock(
help_text='Insert an embed URL e.g https://www.youtube.com/embed/SGJFWirQ3ks',
icon="fa-s15",
template="blocks/embed_block.html")