class ContactEmail(blocks.StructBlock): emails = blocks.ListBlock(atoms.Hyperlink()) class Meta: icon = 'mail' template = '_includes/molecules/contact-email.html' label = 'Email'
class FeaturedContent(blocks.StructBlock): heading = blocks.CharBlock() body = blocks.RichTextBlock() post = blocks.PageChooserBlock(required=False) show_post_link = blocks.BooleanBlock(required=False, label="Render post link?") post_link_text = blocks.CharBlock(required=False) image = atoms.ImageBasic(required=False) links = blocks.ListBlock(atoms.Hyperlink(required=False), label='Additional Links') video = VideoPlayer(required=False) class Meta: template = '_includes/organisms/featured-content.html' icon = 'doc-full-inverse' label = 'Featured Content' classname = 'block__flush' value_class = FeaturedContentStructValue class Media: js = ['featured-content-module.js']
class RelatedMetadata(blocks.StructBlock): slug = blocks.CharBlock(max_length=100) content = blocks.StreamBlock([ ('text', blocks.StructBlock([('heading', blocks.CharBlock(max_length=100)), ('blob', blocks.RichTextBlock())], icon='pilcrow')), ('list', blocks.StructBlock([ ('heading', blocks.CharBlock(max_length=100)), ('links', blocks.ListBlock(atoms.Hyperlink())), ], icon='list-ul')), ('date', blocks.StructBlock([('heading', blocks.CharBlock(max_length=100)), ('date', blocks.DateBlock())], icon='date')), ('topics', blocks.StructBlock([ ('heading', blocks.CharBlock(max_length=100, default='Topics')), ('show_topics', blocks.BooleanBlock(default=True, required=False)) ], icon='tag')), ]) is_half_width = blocks.BooleanBlock(required=False, default=False) class Meta: icon = 'grip' template = '_includes/molecules/related-metadata.html' label = 'Related metadata'
class TextIntroduction(blocks.StructBlock): eyebrow = blocks.CharBlock( required=False, help_text=('Optional: Adds an H5 eyebrow above H1 heading text. ' 'Only use in conjunction with heading.'), label='Pre-heading') heading = blocks.CharBlock(required=False) intro = blocks.RichTextBlock(required=False) body = blocks.RichTextBlock(required=False) links = blocks.ListBlock(atoms.Hyperlink(required=False), required=False) has_rule = blocks.BooleanBlock( required=False, label="Has bottom rule", help_text=('Check this to add a horizontal rule line to bottom of ' 'text introduction.')) def clean(self, value): cleaned = super(TextIntroduction, self).clean(value) # Eyebrow requires a heading. if cleaned.get('eyebrow') and not cleaned.get('heading'): raise ValidationError( 'Validation error in TextIntroduction: ' 'pre-heading requires heading', params={ 'heading': ErrorList(['Required if a pre-heading is entered.']) }) return cleaned class Meta: icon = 'title' template = '_includes/molecules/text-introduction.html' classname = 'block__flush-top'
class Hero(blocks.StructBlock): heading = blocks.CharBlock( required=False, help_text='Maximum character count: 25 (including spaces)') body = blocks.RichTextBlock( required=False, help_text='Maximum character count: 185 (including spaces)') links = blocks.ListBlock( atoms.Hyperlink(), help_text='If your hero needs a call-to-action link, ' 'enter it here, rather than inside the body field.') is_button = blocks.BooleanBlock( required=False, help_text='Select to render any links given above as buttons.') image = ImageChooserBlock( required=False, help_text='Should be exactly 390px tall, and up to 940px wide, ' 'unless this is an overlay or bleeding style hero.') is_overlay = blocks.BooleanBlock( required=False, help_text='Select if you want the provided image to be ' 'a background image under the entire hero.') background_color = blocks.CharBlock( required=False, help_text='Specify a hex value (with the # sign) ' 'from our official palette: ' 'https://github.com/cfpb/cf-theme-cfpb/blob/' 'master/src/color-palette.less') is_white_text = blocks.BooleanBlock( required=False, help_text='Turns the hero text white. Useful if using ' 'a dark background color or background image.') cta_link_color = blocks.CharBlock( required=False, label='CTA link color', help_text='If using a dark background color or background image, ' 'you may need to specify an alternate color ' 'for the call-to-action link. Specify a hex value ' '(with the # sign) from our official palette: ' 'https://github.com/cfpb/cf-theme-cfpb/blob/' 'master/src/color-palette.less') is_bleeding = blocks.BooleanBlock( required=False, help_text='Select if you want the provided image to bleed ' 'vertically off the top and bottom of the hero.') small_image = ImageChooserBlock( required=False, help_text='Provide an alternate image for small displays ' 'when using a bleeding or overlay hero.') class Meta: icon = 'image' template = '_includes/molecules/hero.html' classname = 'block__flush-top block__flush-bottom'
class RelatedLinks(blocks.StructBlock): heading = blocks.CharBlock(required=False) paragraph = blocks.RichTextBlock(required=False) links = blocks.ListBlock(atoms.Hyperlink()) class Meta: icon = 'grip' template = '_includes/molecules/related-content.html' label = 'Related content'
class ImageText2575(blocks.StructBlock): heading = blocks.CharBlock(required=False) body = blocks.RichTextBlock(required=False) image = atoms.ImageBasic() links = blocks.ListBlock(atoms.Hyperlink(), required=False) has_rule = blocks.BooleanBlock(required=False) class Meta: icon = 'image' template = '_includes/molecules/image-text-25-75.html'
class Expandable(BaseExpandable): content = blocks.StreamBlock([ ('paragraph', blocks.RichTextBlock(required=False)), ('well', Well()), ('links', atoms.Hyperlink()), ('email', molecules.ContactEmail()), ('phone', molecules.ContactPhone()), ('address', molecules.ContactAddress()), ], blank=True)
class InfoUnit(blocks.StructBlock): image = atoms.ImageBasic(required=False, ) heading = HeadingBlock(required=False, default={'level': 'h3'}) body = blocks.RichTextBlock(blank=True, required=False) links = blocks.ListBlock(atoms.Hyperlink(), required=False) class Meta: icon = 'image' template = '_includes/molecules/info-unit.html'
class BureauStructureDivision(blocks.StructBlock): division = v1_blocks.PlaceholderCharBlock(label='Division') division_lead = v1_blocks.PlaceholderCharBlock(placeholder="Name") title = blocks.StructBlock([ ('line_1', v1_blocks.PlaceholderCharBlock(required=False, placeholder="Title 1")), ('line_2', v1_blocks.PlaceholderCharBlock(required=False, placeholder="Title 2")) ]) link_to_division_page = atoms.Hyperlink(required=False) offices = blocks.ListBlock(BureauStructurePosition(required=False))
class ImageText5050(blocks.StructBlock): heading = blocks.CharBlock(required=False) body = blocks.RichTextBlock(blank=True, required=False) image = atoms.ImageBasic() is_widescreen = blocks.BooleanBlock(required=False, label="Use 16:9 image") is_button = blocks.BooleanBlock(required=False, label="Show links as button") links = blocks.ListBlock(atoms.Hyperlink(), required=False) class Meta: icon = 'image' template = '_includes/molecules/image-text-50-50.html'
class Table(blocks.StructBlock): headers = blocks.ListBlock(blocks.CharBlock()) rows = blocks.ListBlock(blocks.StreamBlock([ ('hyperlink', atoms.Hyperlink(required=False)), ('text', blocks.CharBlock()), ('text_blob', blocks.TextBlock()), ('rich_text_blob', blocks.RichTextBlock()), ])) class Meta: icon = None template = '_includes/organisms/table.html' label = ' '
class HomePage(CFGOVPage): header = StreamField([ ('info_unit', molecules.InfoUnit()), ('half_width_link_blob', molecules.HalfWidthLinkBlob()), ], blank=True) latest_updates = StreamField([ ('posts', blocks.ListBlock( blocks.StructBlock([ ('categories', blocks.ChoiceBlock(choices=ref.limited_categories, required=False)), ('link', atoms.Hyperlink()), ('date', blocks.DateTimeBlock(required=False)), ]))), ], blank=True) # General content tab content_panels = CFGOVPage.content_panels + [ StreamFieldPanel('header'), StreamFieldPanel('latest_updates'), ] # Tab handler interface edit_handler = TabbedInterface([ ObjectList(content_panels, heading='General Content'), ObjectList(CFGOVPage.sidefoot_panels, heading='Sidebar'), ObjectList(CFGOVPage.settings_panels, heading='Configuration'), ]) # Sets page to only be createable at the root parent_page_types = ['wagtailcore.Page'] template = 'index.html' objects = PageManager() search_fields = CFGOVPage.search_fields + [index.SearchField('header')] def get_category_name(self, category_icon_name): cats = dict(ref.limited_categories) return cats[str(category_icon_name)] def get_context(self, request): context = super(HomePage, self).get_context(request) return context
class TextIntroduction(blocks.StructBlock): heading = blocks.CharBlock(required=False) intro = blocks.RichTextBlock(required=False) body = blocks.RichTextBlock(required=False) links = blocks.ListBlock(atoms.Hyperlink(required=False), required=False) has_rule = blocks.BooleanBlock( required=False, label="Has bottom rule", help_text=('Check this to add a horizontal rule line to bottom of ' 'text introduction.')) class Meta: icon = 'title' template = '_includes/molecules/text-introduction.html' classname = 'block__flush-top'
class Notification(blocks.StructBlock): message = blocks.CharBlock( required=True, help_text='The main notification message to display.') explanation = blocks.TextBlock( required=False, help_text='Explanation text appears below the message in smaller type.' ) links = blocks.ListBlock( atoms.Hyperlink(required=False), required=False, help_text='Links appear on their own lines below the explanation.') class Meta: icon = 'warning' template = '_includes/molecules/notification.html'
class HalfWidthLinkBlob(blocks.StructBlock): heading = blocks.CharBlock(required=False, label="H3 heading") sub_heading = blocks.CharBlock(required=False, label="H4 heading") sub_heading_icon = blocks.CharBlock( required=False, label="H4 heading icon", help_text=( 'A list of icon names can be obtained at: ' 'https://cfpb.github.io/capital-framework/components/cf-icons/. ' 'Examples: linkedin-square, facebook-square, etc.')) body = blocks.RichTextBlock(blank=True, required=False) links = blocks.ListBlock(atoms.Hyperlink(), required=False) class Meta: icon = 'link' template = '_includes/molecules/link-blob.html'
class FeaturedContent(blocks.StructBlock): heading = blocks.CharBlock(required=False) body = blocks.RichTextBlock(required=False) category = blocks.ChoiceBlock(choices=ref.fcm_types, required=False) post = blocks.PageChooserBlock(required=False) show_post_link = blocks.BooleanBlock(required=False, label="Render post link?") post_link_text = blocks.CharBlock(required=False) image = atoms.ImageBasic(required=False) links = blocks.ListBlock(atoms.Hyperlink(required=False), label='Additional Links') video = blocks.StructBlock([ ('id', blocks.CharBlock( required=False, label='ID', help_text='E.g., in "https://www.youtube.com/watch?v=en0Iq8II4fA",' ' the ID is everything after the "?v=".')), ('url', blocks.CharBlock(required=False, label='URL', help_text='You must use the embed URL, e.g., ' 'https://www.youtube.com/embed/' 'JPTg8ZB3j5c?autoplay=1&enablejsapi=1')), ('height', blocks.CharBlock(default='320', required=False)), ('width', blocks.CharBlock(default='568', required=False)), ]) class Meta: template = '_includes/molecules/featured-content.html' icon = 'doc-full-inverse' label = 'Featured Content' classname = 'block__flush' class Media: js = ['video-player.js']
class Notification(blocks.StructBlock): type = blocks.ChoiceBlock(choices=[ ('default', 'Default'), ('success', 'Success'), ('warning', 'Warning'), ('error', 'Error'), ], required=True, default='default') message = blocks.CharBlock( required=True, help_text='The main notification message to display.') explanation = blocks.TextBlock( required=False, help_text='Explanation text appears below the message in smaller type.' ) links = blocks.ListBlock( atoms.Hyperlink(required=False), required=False, help_text='Links appear on their own lines below the explanation.') class Meta: icon = 'warning' template = '_includes/molecules/notification.html'