""" link = FalmerPageChooserBlock(required=True) title = blocks.CharBlock(required=False) @property def get_title(self): if self.title: return self.title else: self.link.title class Meta: icon = 'link' internal_link = Component('internal_link', InternalLink) class DocumentLink(blocks.StructBlock): """ Single Internal link block """ link = DocumentChooserBlock(required=True) title = blocks.CharBlock(required=False) @property def get_title(self): # weird; property with get_ if self.title: return self.title else: self.link.name
import re from wagtail.core.blocks import StructBlock,CharBlock,ListBlock, BooleanBlock, RegexBlock, StreamBlock from falmer.content.components.base import Component from falmer.content.components.buttons import basic_button from falmer.content.components.text import text OPENING_TIME_REGEX = re.compile('[Mo|Tu|We|Th|Fr|Sa|Su|\-|,]+ [0-9]{2}:[0-9]{2}-[0-9]{2}:[0-9]{2}') class OpeningTimesBlock(StructBlock): special_tag = CharBlock(required=False, help_text='Add a little label if these are unusual opening times, for instance holidays') times = ListBlock(RegexBlock(OPENING_TIME_REGEX, required=True, help_text='Please see our docs for opening times formatting')) enabled = BooleanBlock(required=False, help_text='Disable for non-used opening times, for instance holidays') opening_times = Component('opening_times', OpeningTimesBlock) class SidebarCard(StructBlock): heading = CharBlock(required=True) content = StreamBlock([ text.to_pair(), basic_button.to_pair(), ]) sidebar_card = Component('sidebar_card', SidebarCard)
from wagtail.core.blocks import StructBlock, RichTextBlock, ChoiceBlock from falmer.content.components.base import Component from .text import TextBlock class CalloutBlock(StructBlock): value = TextBlock() variant = ChoiceBlock(label='Variant', choices=( ('info', 'Info'), ('warning', 'Warning'), ('alert', 'Alert'), )) callout = Component('callout', CalloutBlock)
from wagtail.core.blocks import StructBlock, RichTextBlock from falmer.content.components.base import Component class TextBlock(StructBlock): value = RichTextBlock() text = Component('text', TextBlock)
from wagtail.core import blocks from falmer.content.blocks import FalmerPageChooserBlock from falmer.content.components.base import Component class StartButton(blocks.StructBlock): title = blocks.CharBlock(required=False) page = FalmerPageChooserBlock(required=False) link = blocks.URLBlock(required=False) start_button = Component('start_button', StartButton) class BasicButton(blocks.StructBlock): title = blocks.CharBlock(required=False) page = FalmerPageChooserBlock(required=False) link = blocks.URLBlock(required=False) basic_button = Component('basic_button', BasicButton)
from wagtail.core import blocks from falmer.content.blocks import FalmerImageChooserBlock from falmer.content.components.base import Component class ImageBlock(blocks.StructBlock): """ Block for single images with all necessary attributes such as alternative title, caption and so on. """ image = FalmerImageChooserBlock(required=True) alternative_title = blocks.CharBlock(required=False) caption = blocks.CharBlock(required=False) @property def get_title(self): if self.alternative_title: return self.alternative_title else: self.image.title class Meta: icon = 'image' image = Component('image', ImageBlock)
col_one_title = blocks.CharBlock(required=True) col_one_content = StreamBlock([ components.text.to_pair(), components.internal_link.to_pair(), components.external_link.to_pair(), ]) col_two_title = blocks.CharBlock(required=True) col_two_content = StreamBlock([ components.text.to_pair(), components.internal_link.to_pair(), components.external_link.to_pair(), ]) two_slice_component = Component('two_slice_component', TwoSlice) class ProfileSlice(blocks.StructBlock): title = blocks.CharBlock(required=True) description = blocks.TextBlock(required=True) menu_name = blocks.CharBlock(required=True) background_color = blocks.CharBlock(required=True, max_length=7) body = StreamBlock([ components.text.to_pair(), components.internal_link.to_pair(), components.external_link.to_pair(), ])
from falmer.content.blocks import RichTextWithExpandedContent from falmer.content.components.base import Component class CalloutBlock(StructBlock): value = TextBlock() variant = ChoiceBlock(label='Variant', choices=( ('info', 'Info'), ('alert', 'Alert'), )) callout = Component('callout', CalloutBlock) class AlertBlock(StructBlock): value = RichTextWithExpandedContent(features=[ 'italic', ]) alert = Component('alert_text', AlertBlock) class InsetBlock(StructBlock): value = RichTextWithExpandedContent(features=[ 'italic', ])