1
Fork 0

Setup workflow for blocks

This commit is contained in:
Jake Howard 2016-12-03 20:49:24 +00:00
parent 682fc92361
commit d7e01f75d7
4 changed files with 35 additions and 9 deletions

View file

@ -2,11 +2,27 @@ from wagtail.wagtailcore.fields import StreamField
from wagtail.wagtailcore import blocks from wagtail.wagtailcore import blocks
def build_stream_field(): def build_header_fields():
return StreamField([ for i in range(6):
('h1', blocks.CharBlock(classname="h1", label="H1")), h_tag = "h" + str(i + 1)
('h2', blocks.CharBlock(classname="h2", label="H2")), 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()), ('paragraph', blocks.RichTextBlock()),
('raw_html', blocks.RawHTMLBlock(label="Raw HTML")), ('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)

View file

@ -31,7 +31,7 @@ INSTALLED_APPS = [
'wagtail.contrib.settings', 'wagtail.contrib.settings',
"wagtail.contrib.table_block", "wagtail.contrib.table_block",
'wagtail.contrib.wagtailstyleguide',
'modelcluster', 'modelcluster',
'taggit', 'taggit',

View 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>

View file

@ -9,9 +9,9 @@
<section> <section>
<div class="container"> <div class="container">
<p class="text-right small"> <p class="text-right small">
Updated: {{ page.date|datetime }} Updated: {{ page.date }}
</p> </p>
{{ page.body|richtext }} {% include_block page.body %}
</div> </div>
</section> </section>
<div class="container text-center"> <div class="container text-center">