Setup workflow for blocks
This commit is contained in:
parent
682fc92361
commit
d7e01f75d7
4 changed files with 35 additions and 9 deletions
|
@ -2,11 +2,27 @@ from wagtail.wagtailcore.fields import StreamField
|
|||
from wagtail.wagtailcore import blocks
|
||||
|
||||
|
||||
def build_stream_field():
|
||||
return StreamField([
|
||||
('h1', blocks.CharBlock(classname="h1", label="H1")),
|
||||
('h2', blocks.CharBlock(classname="h2", label="H2")),
|
||||
def build_header_fields():
|
||||
for i in range(6):
|
||||
h_tag = "h" + str(i + 1)
|
||||
yield (h_tag, blocks.CharBlock(classname=h_tag, label=h_tag.upper(), icon="title"))
|
||||
|
||||
|
||||
def build_fixed_fields():
|
||||
return [
|
||||
('list', blocks.ListBlock(blocks.CharBlock(label="List Item"), label="list-ul")),
|
||||
('paragraph', blocks.RichTextBlock()),
|
||||
('raw_html', blocks.RawHTMLBlock(label="Raw HTML")),
|
||||
('list', blocks.ListBlock(blocks.CharBlock(label="List Item")))
|
||||
])
|
||||
('secret', blocks.RichTextBlock(icon="password", template='blocks/secret.html')),
|
||||
]
|
||||
|
||||
|
||||
def build_stream_field():
|
||||
fields = []
|
||||
for field_builder in [
|
||||
build_header_fields,
|
||||
build_fixed_fields
|
||||
]:
|
||||
for field in field_builder():
|
||||
fields.append(field)
|
||||
return StreamField(fields)
|
||||
|
|
|
@ -31,7 +31,7 @@ INSTALLED_APPS = [
|
|||
|
||||
'wagtail.contrib.settings',
|
||||
"wagtail.contrib.table_block",
|
||||
|
||||
'wagtail.contrib.wagtailstyleguide',
|
||||
'modelcluster',
|
||||
'taggit',
|
||||
|
||||
|
|
10
templates/blocks/secret.html
Normal file
10
templates/blocks/secret.html
Normal file
|
@ -0,0 +1,10 @@
|
|||
{% load wagtailcore_tags %}
|
||||
|
||||
<button class="btn btn-primary btn-block" type="button" data-toggle="collapse" data-target="#secret-block" aria-expanded="false" aria-controls="secret-block">
|
||||
Show Secret
|
||||
</button>
|
||||
<div class="collapse" id="secret-block">
|
||||
<div class="well">
|
||||
{{ value }}
|
||||
</div>
|
||||
</div>
|
|
@ -9,9 +9,9 @@
|
|||
<section>
|
||||
<div class="container">
|
||||
<p class="text-right small">
|
||||
Updated: {{ page.date|datetime }}
|
||||
Updated: {{ page.date }}
|
||||
</p>
|
||||
{{ page.body|richtext }}
|
||||
{% include_block page.body %}
|
||||
</div>
|
||||
</section>
|
||||
<div class="container text-center">
|
||||
|
|
Reference in a new issue