Skip to content

Commit

Permalink
Merge pull request #1260 from devinit/feature/blog-table
Browse files Browse the repository at this point in the history
 Add table block to blog page body
  • Loading branch information
ThatcherK authored Nov 16, 2022
2 parents 4143c5a + 6441f60 commit d0c87d0
Showing 1 changed file with 30 additions and 2 deletions.
32 changes: 30 additions & 2 deletions di_website/common/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
ListBlock, PageChooserBlock, RichTextBlock,
StreamBlock, StructBlock, TextBlock, URLBlock)
from wagtail.documents.blocks import DocumentChooserBlock
from wagtail.contrib.table_block.blocks import TableBlock
from wagtail.embeds.blocks import EmbedBlock
from wagtail.images.blocks import ImageChooserBlock

from di_website.common.constants import (RICHTEXT_FEATURES,
from di_website.common.constants import (FOOTNOTE_RICHTEXT_FEATURES, RICHTEXT_FEATURES,
RICHTEXT_FEATURES_NO_FOOTNOTES)
from di_website.publications.blocks import AudioMediaBlock
from di_website.publications.infographic import Infographic
Expand Down Expand Up @@ -301,7 +302,6 @@ class Meta:
label = 'Call To Action'
template = 'blocks/call_to_action.html'


class TypesetStreamBlock(StreamBlock):
"""
The custom blocks that can be used under an element with the typeset class (not sections)
Expand Down Expand Up @@ -333,6 +333,33 @@ class Meta:
template = 'blocks/basic_infographic.html'


class Table(StructBlock):

class Meta:
help_text = 'Displays tabular data with an optional heading.'
icon = 'list-ol'
label = 'Table'
form_template = 'publications/block_forms/custom_struct.html'
template = 'publications/blocks/table.html'

heading = CharBlock(
required=False
)
table = TableBlock()
caption = RichTextBlock(
required=False,
features=FOOTNOTE_RICHTEXT_FEATURES,
help_text='Optional: caption text to appear below the table'
)
caption_link = URLBlock(
required=False,
help_text='Optional: external link to appear below the table'
)
caption_label = CharBlock(
required=False,
help_text='Optional: label for the caption link, defaults to the link if left blank'
)

class TypesetFootnoteStreamBlock(StreamBlock):
"""
The custom blocks that can be used under an element with the typeset class (not sections)
Expand All @@ -355,6 +382,7 @@ class TypesetFootnoteStreamBlock(StreamBlock):
)
infographic = BasicInfographicBlock()
cta = CallToActionBlock()
table = Table()

required = False

Expand Down

0 comments on commit d0c87d0

Please sign in to comment.