1
Fork 0
This repository has been archived on 2023-03-26. You can view files and clone it, but cannot push or open issues or pull requests.
theorangeone.net-legacy/project/common/fields.py

36 lines
1.3 KiB
Python
Raw Normal View History

2016-11-28 22:20:42 +00:00
from wagtail.wagtailcore.fields import StreamField
from wagtail.wagtailcore import blocks
2016-12-03 22:56:49 +00:00
from wagtail.wagtailimages.blocks import ImageChooserBlock
from wagtail.wagtaildocs.blocks import DocumentChooserBlock
2016-11-28 22:20:42 +00:00
2016-12-03 20:49:24 +00:00
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 [
2016-12-03 22:56:49 +00:00
('ansi', blocks.TextBlock(template="blocks/ansi.html")),
('document', DocumentChooserBlock()),
('gist', blocks.CharBlock(template="blocks/gist.html")),
('image', ImageChooserBlock()),
('ol', blocks.ListBlock(blocks.CharBlock(label="List Item"), label="Ordered List", template='blocks/ordered-list.html')),
2016-11-28 22:20:42 +00:00
('paragraph', blocks.RichTextBlock()),
('raw_html', blocks.RawHTMLBlock(label="Raw HTML")),
2016-12-03 20:49:24 +00:00
('secret', blocks.RichTextBlock(icon="password", template='blocks/secret.html')),
2016-12-03 22:56:49 +00:00
('ul', blocks.ListBlock(blocks.CharBlock(label="List Item"), label="Unordered List")),
2016-12-03 20:49:24 +00:00
]
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)