class ExpandableGroup(BaseExpandableGroup): body = blocks.RichTextBlock(required=False) is_accordion = blocks.BooleanBlock(required=False) has_top_rule_line = blocks.BooleanBlock( default=False, required=False, help_text=('Check this to add a horizontal rule line to top of ' 'expandable group.') ) expandables = blocks.ListBlock(Expandable())
class MapBlock(StructBlock): people = blocks.BooleanBlock(label=_('Users'), required=False, default=True) events = blocks.BooleanBlock(label=_('Events'), required=False, default=True) projects = blocks.BooleanBlock(label=_('Projects'), required=False, default=True) groups = blocks.BooleanBlock(label=_('Groups'), required=False, default=True) class Meta(object): icon = 'site' template = 'cosinnus/wagtail/widgets/map.html' def clean(self, value): ret = super(MapBlock, self).clean(value) if not any([ bool(value.get(val)) for val in ('people', 'events', 'projects', 'groups') ]): errors = dict([ (val, ErrorList( [_('At least one type of Map object must be chosen!')])) for val in ('people', 'events', 'projects', 'groups') ]) raise ValidationError( _('At least one type of Map object must be chosen!'), params=errors) return ret def get_context(self, value): context = super(MapBlock, self).get_context(value) """ Map settings look like this: map_settings = { 'availableFilters': {'people': True, 'events': True, 'projects': True, 'groups': True}, 'activeFilters': {'people': True, 'events': True, 'projects': True, 'groups': True} } """ map_switches = dict([(kind, bool(value.get(kind))) for kind in ('people', 'events', 'projects', 'groups')]) map_settings = { 'availableFilters': map_switches, 'activeFilters': map_switches, 'topicsJson': render_cosinnus_topics_json(), } context['map_settings'] = json.dumps(map_settings) return context
class MediaFileBirdBlock(blocks.StructBlock): muted = blocks.BooleanBlock(required=False, default=True, help_text='Muted') autoplay = blocks.BooleanBlock(required=False, default=False, help_text='Autoplay') loop = blocks.BooleanBlock(required=False, default=False, help_text='Loop') controls = blocks.BooleanBlock(required=False, default=True, help_text='Controls') block_media = AbstractMediaChooserBlock() class Meta: label = 'MediaFile' icon = 'media' template = 'blocks/media_file.html'
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 ResourceList(blocks.StructBlock): heading = blocks.CharBlock(required=False) body = blocks.RichTextBlock(required=False) has_top_rule_line = blocks.BooleanBlock( default=False, required=False, help_text='Check this to add a horizontal rule line above this block.') image = atoms.ImageBasic(required=False) actions_column_width = blocks.ChoiceBlock( label='Width of "Actions" column', required=False, help_text='Choose the width in % that you wish to set ' 'the Actions column in a resource list.', choices=[ ('70', '70%'), ('66', '66%'), ('60', '60%'), ('50', '50%'), ('40', '40%'), ('33', '33%'), ('30', '30%'), ], ) show_thumbnails = blocks.BooleanBlock( required=False, help_text='If selected, each resource in the list will include a ' '150px-wide image from the resource\'s thumbnail field.') actions = blocks.ListBlock( blocks.StructBlock([ ('link_label', blocks.CharBlock( help_text='E.g., "Download" or "Order free prints"')), ('snippet_field', blocks.ChoiceBlock( choices=[ ('related_file', 'Related file'), ('alternate_file', 'Alternate file'), ('link', 'Link'), ('alternate_link', 'Alternate link'), ], help_text='The field that the action link should point to')), ])) tags = blocks.ListBlock( blocks.CharBlock(label='Tag'), help_text='Enter tag names to filter the snippets. For a snippet to ' 'match and be output in the list, it must have been tagged ' 'with all of the tag names listed here. The tag names ' 'are case-insensitive.') class Meta: label = 'Resource List' icon = 'table' template = '_includes/organisms/resource-list.html'
class FormView(blocks.StructBlock): #text_color = SnippetChooserBlock('home.Colors', blank=True) use_container = blocks.BooleanBlock(required=False) use_simple_button = blocks.BooleanBlock(required=False, default=True) text_submit = blocks.CharBlock(default="Submit") text_submit_2 = blocks.CharBlock(default="Send", label="Only for complex button") class Meta: template = 'tmps/tmp_form_view.html' icon = 'placeholder' label = 'Form View (only Form Page)'
class BaseExpandable(blocks.StructBlock): label = blocks.CharBlock(required=False) is_bordered = blocks.BooleanBlock(required=False) is_midtone = blocks.BooleanBlock(required=False) is_expanded = blocks.BooleanBlock(required=False) class Meta: icon = 'list-ul' template = '_includes/organisms/expandable.html' label = 'Expandable' class Media: js = ["expandable.js"]
class MasonryBlock(blocks.StructBlock): title = blocks.CharBlock() tiles = blocks.ListBlock(blocks.StructBlock([ ('image', ImageChooserBlock()), ('page', blocks.PageChooserBlock()), ('featured_x', blocks.BooleanBlock(required=False)), ('featured_y', blocks.BooleanBlock(required=False)), ('featured_mobile', blocks.BooleanBlock(required=False)), ('title_dark', blocks.BooleanBlock(required=False)), ])) class Meta: template = 'main/blocks/masonry.html'
class CTABlock(blocks.StructBlock): image_meta = blocks.TextBlock(required=False, classname='dct-meta-field') mobile_use_renditions = blocks.BooleanBlock(default=True, required=False, classname='dct-meta-field') desktop_use_renditions = blocks.BooleanBlock(default=True, required=False, classname='dct-meta-field') def get_api_representation(self, value, context=None): # recursively call get_api_representation on children and return as a plain dict image_meta = value.get('image_meta') context['image_meta'] = image_meta result = dict([ (name, self.child_blocks[name].get_api_representation(val, context=context)) for name, val in value.items() ]) # FROM HERE DOWN TO IF CTA IS ALL LEGACY STUFF, IT HANDLES ANY IMAGE CHOOSER THAT IS NOT PART OF AN IMAGE BLOCK image_fields = [] for k, v in value.items(): from images.models import PHEImage if type(v) == PHEImage: image_fields.append(k) for image_field in image_fields: if image_field in result: if result[image_field].get('renditions'): mobile_rendition = None desktop_rendition = None if image_meta and result['mobile_use_renditions']: mobile_rendition = result[image_field]['renditions'].get(image_meta + '/mobile') if not mobile_rendition: mobile_rendition = result[image_field]['renditions']['original'] if image_meta and result['desktop_use_renditions']: desktop_rendition = result[image_field]['renditions'].get(image_meta + '/desktop') if not desktop_rendition: desktop_rendition = result[image_field]['renditions']['original'] result[image_field]['renditions'] = { 'mobile': mobile_rendition, 'desktop': desktop_rendition } if 'cta' in result: cta_links = [] for link in result['cta']: cta_links.append(link['value']) result['cta'] = cta_links return result
class NavGroup(blocks.StructBlock): draft = blocks.BooleanBlock( required=False, default=False, help_text='If checked, this block will only show ' 'on our sharing site (Content).', label='Mark block as draft') group_title = blocks.CharBlock(required=False, label='Column title') hide_group_title = blocks.BooleanBlock( required=False, label='Hide column title', help_text='If column shares title with previous column, ' 'enter title text above but check this box so title ' 'only shows in first column.') nav_items = blocks.ListBlock(NavItem(), required=False, label='Menu items')
class SubsectionBlock(blocks.StructBlock): subsection = blocks.CharBlock() collapsed = blocks.BooleanBlock(required=False, default=True) class Meta: icon = 'collapse-up' template = 'dalme_public/blocks/_subsection.html'
class EmailSignUp(blocks.StructBlock): heading = blocks.CharBlock(required=False, default='Stay informed') default_heading = blocks.BooleanBlock( required=False, default=True, label='Default heading style', help_text=('If selected, heading will be styled as an H5 ' 'with green top rule. Deselect to style header as H3.') ) text = blocks.CharBlock( required=False, help_text=('Write a sentence or two about what kinds of emails the ' 'user is signing up for, how frequently they will be sent, ' 'etc.') ) gd_code = blocks.CharBlock( required=False, label='GovDelivery code', help_text=('Code for the topic (i.e., mailing list) you want people ' 'who submit this form to subscribe to. Format: USCFPB_###') ) disclaimer_page = blocks.PageChooserBlock( required=False, label='Privacy Act statement', help_text=('Choose the page that the "See Privacy Act statement" link ' 'should go to. If in doubt, use "Generic Email Sign-Up ' 'Privacy Act Statement".') ) class Meta: icon = 'mail' template = '_includes/organisms/email-signup.html' class Media: js = ['email-signup.js']
class RegComment(blocks.StructBlock): document_id = blocks.CharBlock( required=True, label='Document ID', help_text=('Federal Register document ID number to which the comment ' 'should be submitted. Should follow this format: ' 'CFPB-YYYY-####-####') ) generic_regs_link = blocks.BooleanBlock( required=False, default=True, label='Use generic Regs.gov link?', help_text=('If unchecked, the link to comment at Regulations.gov if ' 'you want to add attachments will link directly to the ' 'document given above. Leave this checked if this comment ' 'form is being published before the full document is live ' 'at Regulations.gov, then uncheck it when the full ' 'document has been published.') ) id = blocks.CharBlock( required=False, label='Form ID', help_text=('Sets the `id` attribute in the form\'s markup. If not ' 'set, the form will be assigned a base id of ' '`o-reg-comment_` with a random number appended.') ) class Meta: icon = 'form' template = '_includes/organisms/reg-comment.html'
class _S_WhyBlock(blocks.StructBlock): why_background = ColorBlock( null=True, blank=False, help_text="Select background color that contrasts text") why_head = blocks.CharBlock(null=True, blank=False, classname="full title", help_text="Bold header text") why_displayhead = blocks.BooleanBlock( null=True, blank=True, default=True, required=False, help_text="Whether or not to display the header") why_collum1 = Why_CollumBlock(null=True, blank=False, icon='cogs', help_text="Left block") why_collum2 = Why_CollumBlock(null=True, blank=False, icon='cogs', help_text="Middle block") why_collum3 = Why_CollumBlock(null=True, blank=False, icon='cogs', help_text="Right block") why_button = SnippetChooserBlock( Button, null=True, blank=True, required=False, help_text="Button displayed at why-section")
class WorkExperienceBlock(blocks.StructBlock): class Meta: template = "wagtail_resume/blocks/work_experience_block.html" icon = "doc-full-inverse" heading = blocks.CharBlock(default="Work experience") fa_icon = blocks.CharBlock(default="fas fa-tools") experiences = blocks.ListBlock( blocks.StructBlock( [ ("role", blocks.CharBlock()), ("company", blocks.CharBlock()), ("url", blocks.URLBlock()), ("from_date", blocks.DateBlock()), ("to_date", blocks.DateBlock(required=False)), ( "currently_working_here", blocks.BooleanBlock( help_text= "Check this box if you are currently working here and it will indicate so on the resume.", required=False, ), ), ("text", MarkdownBlock()), ], icon="folder-open-inverse", ))
class _S_LabBlock(blocks.StructBlock): lab_background = ColorBlock( null=True, blank=False, help_text="Select background color that contrasts text") lab_head = blocks.CharBlock(null=True, blank=False, classname="full title") lab_displayhead = blocks.BooleanBlock( null=True, blank=True, required=False, help_text="Display block head if it fits the design context") lab_image = ImageChooserBlock(null=True, blank=False) lab_lead = blocks.RichTextBlock( null=True, blank=False, features=[ 'bold', 'italic', 'underline', 'strikethrough', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'blockquote', 'ol', 'ul', 'hr', 'embed', 'link', 'superscript', 'subscript', 'document-link', 'image', 'code' ], classname="full") lab_paragraph = blocks.RichTextBlock( null=True, blank=False, features=[ 'bold', 'italic', 'underline', 'strikethrough', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'blockquote', 'ol', 'ul', 'hr', 'embed', 'link', 'superscript', 'subscript', 'document-link', 'image', 'code' ], classname="full") lab_button = SnippetChooserBlock(Button, null=True, blank=True, required=False)
class SegmentBlock(blocks.StructBlock): extra_klasses = blocks.CharBlock( required=False, help_text='semantic ui classes (eg: raised ...') header = blocks.RichTextBlock(required=False, help_text='Can leave blank') content = blocks.RichTextBlock( required=False, help_text='template tags are available eg: {{ user }} ,' ' {{ last_login }}, {{ now }}, {{ today }} {{request }}') divider = blocks.BooleanBlock(required=False) boxed = blocks.BooleanBlock(required=False) class Meta: icon = 'user' label = 'Segment' admin_text = 'Segment' template = 'home/blocks/segment.html'
class MovieBlock(blocks.StructBlock): heading = blocks.CharBlock(label="Überschrift", required=False) highlight_in_heading = blocks.CharBlock( label="Hervorhebungen in der Überschrift", help_text= "Wiederhole Text aus der Überschrift der farblich hervorgehoben werden soll", required=False, ) white_background = blocks.BooleanBlock(label="weißer Hintergrund", required=False) background = ImageChooserBlock(label="Hintergrund-Bild", required=False) url = blocks.URLBlock(label="URL", required=True, help_text="URL zu dem Video, auf das verlinkt wird") image = ImageChooserBlock( label="Bild (schwarz wenn nichts angegeben)", required=False, ) caption = blocks.CharBlock(label="Bildunterschrift", required=False) class Meta: label = "Film-Block" template = "blocks/homepage_movie.html" icon = "media"
class PDFDownloadBlock(blocks.StructBlock, ThemeableBlock): file = DocumentChooserBlock(required=True) button_text = blocks.CharBlock( required=False, help_text= 'Optional text to replace the button text. If left empty, the button will read "Download PDF".' ) display = blocks.BooleanBlock(default=True) def get_template(self, context, *args, **kwargs): standard_template = super(PDFDownloadBlock, self).get_template(context, *args, **kwargs) return self.get_theme_template(standard_template, context, 'pdf_download_block') def get_api_representation(self, value, context=None): if value: return { 'button_text': value.get('button_text'), 'url': value.get('file').file.url, } class Meta: icon = 'download-alt' label = 'PDF Download'
class _S_ContentLeftBlock(blocks.StructBlock): cl_image = ImageChooserBlock(label='Image', null=True, blank=False, required=True, help_text="Select an image") cl_head = blocks.CharBlock(label='Head', null=True, blank=False, required=True, classname="full title", help_text="Bold header text") cl_lead = blocks.CharBlock(label='Lead', null=True, blank=False, required=False, help_text="The content of this element") cl_text = blocks.RichTextBlock(label='Text', null=True, blank=False, required=True) cl_button = SnippetChooserBlock(Button, label='Button', null=True, blank=False, required=False, help_text="Button for Content Left") cl_center = blocks.BooleanBlock(label='Align center', help_text='Align center', required=False)
class HomepageGroupsBlock(blocks.StructBlock): heading = blocks.CharBlock(label="Überschrift", required=False) highlight_in_heading = blocks.CharBlock( label="Hervorhebungen in der Überschrift", help_text= "Wiederhole Text aus der Überschrift der farblich hervorgehoben werden soll", required=False, ) white_background = blocks.BooleanBlock(label="weißer Hintergrund", required=False) background = ImageChooserBlock(label="Hintergrund-Bild", required=False) def get_context(self, value, parent_context=None): # to prevent circular import from core.models import ( # pylint: disable=import-outside-toplevel Group, GroupIndexPage, ) context = super().get_context(value, parent_context=parent_context) try: group_index_page = GroupIndexPage.objects.get() except Exception: return context context["groups"] = ( Group.objects.child_of(group_index_page).live().filter( list_on_group_index_page=True)) return context class Meta: label = "JANUN-Gruppen" template = "blocks/homepage_groups.html" icon = "image"
class ContactPhone(blocks.StructBlock): fax = blocks.BooleanBlock(default=False, required=False, label='Is this number a fax?') phones = blocks.ListBlock( blocks.StructBlock([ ('number', blocks.CharBlock( max_length=15, help_text='Do not include spaces or dashes. Ex. 8554112372', validators=[phone_number_format_validator()])), ('extension', blocks.CharBlock(max_length=4, required=False)), ('vanity', blocks.CharBlock( max_length=15, required=False, help_text='A phoneword version of the above number. ' 'Include any formatting. Ex. (555) 222-CFPB')), ('tty', blocks.CharBlock( max_length=15, required=False, label="TTY", help_text='Do not include spaces or dashes. Ex. 8554112372', validators=[phone_number_format_validator()])), ('tty_ext', blocks.CharBlock(max_length=4, required=False, label="TTY Extension")), ])) class Meta: icon = 'mail' template = '_includes/molecules/contact-phone.html' label = 'Phone'
class _S_AboutBlock(blocks.StructBlock): about_head = blocks.CharBlock(null=True, blank=False, classname="full title", help_text="Bold header text") about_displayhead = blocks.BooleanBlock( null=True, blank=True, default=True, required=False, help_text="Whether or not to display the header") about_card1 = About_CardBlock(null=True, blank=False, icon='cogs', help_text="Upper Left") about_card2 = About_CardBlock(null=True, blank=False, icon='cogs', help_text="Upper Right") about_card3 = About_CardBlock(null=True, blank=False, icon='cogs', help_text="Lower Left") about_card4 = About_CardBlock(null=True, blank=False, icon='cogs', help_text="Lower Right")
class BootstrapCol(blocks.StructBlock): width = blocks.IntegerBlock(max_value=12, min_value=0, help_text='0 = auto', default=0) alignment = blocks.ChoiceBlock(choices=[ ('center', 'Center'), ('right', 'Right'), ('left', 'Left'), ], default='center') vertical_center = blocks.BooleanBlock(default=False, blank=True, required=False) body = blocks.StreamBlock([ (_('Rich_Text'), blocks.RichTextBlock()), (_('Text'), blocks.TextBlock()), (_('Image'), ImageChooserBlock(icon="image")), (_('Embedded_Video'), EmbedBlock(icon="media")), (_('HTML'), blocks.RawHTMLBlock()), (_('Quote'), blocks.BlockQuoteBlock()), (_('Optin'), OptinChooserBlock('optin.Optin')), (_('Code'), CodeBlock(label='Code Editor')), (_('Aligned_Image'), AlignedImageBlock()), ], blank=True, null=True, required=False) class Meta: icon = 'grip' label = 'Bootstrap Col' template = 'blog/blocks/bootstrap_col.html'
class SimplePageHeadingShelf(Shelf, WithTracking): heading = blocks.CharBlock(required=False) display_back_button = blocks.BooleanBlock(label='Display a back button', required=False, default=True) back_button_label = blocks.CharBlock(required=False) class Meta: form_classname = 'dct-simple-page-heading-shelf dct-meta-panel'
class HorizontalCardsBlock(blocks.StructBlock): """ Cards with image and title else """ # title = blocks.CharBlock(required=False, help_text='Add a title for the cards if necessary, ') cards = blocks.ListBlock( blocks.StructBlock([ ('image', images_blocks.ImageChooserBlock( required=True, help_text='Use a 400x300px picture,')), ('title', blocks.CharBlock(max_length=48, required=False)), ('subtitle', blocks.TextBlock(max_length=48, required=False)), ('text', blocks.TextBlock(max_length=256, required=False)), ('link_page', blocks.PageChooserBlock(required=False)), ('link_url', blocks.URLBlock(required=False)), ('link_text', blocks.CharBlock(max_length=32, required=False)), ('reverse', blocks.BooleanBlock(required=False, help_text="Place image to the right?")) ])) class Meta: template = 'streams/fullwidthcards_block.html' icon = 'placeholder' label = 'Full width cards'
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 _S_AboutBlock(blocks.StructBlock): about_background = ColorBlock( null=True, blank=False, help_text="Select background color that contrasts text") about_image = ImageChooserBlock(null=True, blank=False, help_text="Office-fitting image") about_displayhead = blocks.BooleanBlock( null=True, blank=True, default=True, required=False, help_text="Whether or not to display the header") about_head = blocks.CharBlock(null=True, blank=False, classname="full title", help_text="Bold header text") about_paragraph = blocks.RichTextBlock( null=True, blank=False, help_text="Paragraph about the company", features=[ 'bold', 'italic', 'underline', 'strikethrough', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'blockquote', 'ol', 'ul', 'hr', 'embed', 'link', 'superscript', 'subscript', 'document-link', 'image', 'code' ], classname="full")
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 ParagraphBlock(blocks.StructBlock): text = blocks.RichTextBlock() use_dropcap = blocks.BooleanBlock(required=False) class Meta: template = "articles/blocks/paragraph_block.html" icon = "doc-full"