class TeamMemberBlock(StructBlock): name = CharBlock(required=True, max_length=80, label='Name') image = ImageChooserBlock(required=True, label='Photo') role = CharBlock(required=True, max_length=80, label='Role / Job Title') biography = TextBlock(required=False, label='Bio') linkedin = URLBlock(required=False, label='LinkedIn Page') twitter = URLBlock(required=False, label='Twitter Page') class Meta: icon = 'user' label = 'Team Member'
class Impressum(Orderable): page = ParentalKey('app_challenges.Challenge', on_delete=models.CASCADE, related_name='impressum') data = StreamField( [ ('heading', RichTextBlock(features=['h2'], icon='title', label='Überschrift')), ('paragraph', RichTextBlock(features=['bold', 'italic', 'link', 'ul', 'ol'], icon='pilcrow', label='Text')), ('image', ImageChooserBlock(icon='image', label='Bild')), ('gallery', GalleryBlock()), ('video', URLBlock(icon='media', label='Video', help_text='Hier Video-URL einfügen')), ], null=True, blank=True, verbose_name='Impressum / Datenschutz / Weitere Hinweise') panels = [ StreamFieldPanel('data'), ]
class GraphicLinkGridItemBlock(StructBlock): image = ImageChooserBlock() title = TextBlock(required=False) subtitle = TextBlock(required=False) link = URLBlock(required=False) def get_context(self, value, parent_context=None): context = super().get_context(value, parent_context=parent_context) def formatted_title(): title = value['title'] if '& ' in title: split_title = title.rsplit('& ') formatted_title = split_title[0] + '& ' + split_title[ 1] else: formatted_title = None return formatted_title context['formatted_title'] = formatted_title() return context class Meta: icon = 'fa-icon-th' template = 'blocks/graphic_link_item.html' help_text = 'Select an image and add a caption (optional).'
class FocusItem(AbstractHighlight): """Class to define the focus item in a navigation menu.""" class Meta: help_text = ''' <strong>Focus item module</strong><br> Internal page link, short description, and link label.<br> Optional: external url for secondary link, display secondary link as button. ''' icon = 'pick' template = 'navigation/blocks/focus_item.html' external_url = URLBlock( help_text= 'Optional: external URL for the secondary link. Defaults to the selected page link', required=False, ) link_label_en = CharBlock( help_text='Label for the secondary page link', label='Link label [en]', ) link_label_fr = CharBlock( help_text='Label for the secondary page link', label='Link label [fr]', required=False, ) use_button_style = BooleanBlock( help_text= 'Optional: if checked, the secondary link will display as a button', required=False, )
class LinkBlock(StructBlock): title = CharBlock(required=True) picture = ImageChooserBlock(required=False) text = RichTextBlock(required=False) link = URLBlock(required=False) date = DateBlock(required=False) class Meta: classname = 'link' icon = 'fa fa-external-link' template = 'widgets/page-teaser-wide.html' def get_context(self, value, parent_context=None): context = super(LinkBlock, self).get_context(value, parent_context=parent_context) context['arrow_right_link'] = True context['title'] = value.get('title') context['description'] = value.get('text') context['date'] = value.get('date') image = value.get('picture') if image: rendition = image.get_rendition('fill-640x360-c100') context['image'] = {'url': rendition.url, 'name': image.title} if value.get('link'): context['href'] = value.get('link') return context
class PaperBlock(StructBlock): picture = ImageChooserBlock(required=False) author = CharBlock() title = CharBlock() journal = CharBlock() link = URLBlock() class Meta: icon = 'fa fa-file-text' template = 'widgets/page-teaser.html' def get_context(self, value, parent_context=None): context = super(PaperBlock, self).get_context(value, parent_context=parent_context) c_update = { 'author': value.get('author'), 'title': value.get('title'), 'description': value.get('journal'), 'href': value.get('link'), 'external_link': True, 'external_link_text': 'Link', 'magicgrow': True, 'border': True, } context.update(c_update) image = value.get('picture') if image: rendition = image.get_rendition('fill-640x360-c100') context['image'] = {'url': rendition.url, 'name': image.title} # context['source'] = {'description': 'Link to paper', 'href': value.get('link')} return context
class Contact(ClusterableModel): name = models.CharField(max_length=DEFAULT_MAX_LENGTH) email = models.EmailField() phone = models.CharField(max_length=DEFAULT_MAX_LENGTH) location = models.ForeignKey(Location, null=True, blank=True, related_name='+', on_delete=models.SET_NULL) social_media = StreamField( [ ('url', URLBlock( label='Social media url' )) ], verbose_name='Links to any social media pages', help_text='For example: https://www.facebook.com/atxpoliceoversight/', blank=True ) panels = [ FieldPanel('name'), FieldPanel('email'), FieldPanel('phone'), SnippetChooserPanel('location'), InlinePanel('hours', label='Hours'), StreamFieldPanel('social_media'), ] def __str__(self): return self.name
class FeatureBlock(StructBlock): heading = CharBlock( required=True, max_length=80, label='Feature', help_text="Feature name. Keep it short, like 'Free Chat' or 'Secure',", classname='block_content_field') description = TextBlock(required=True, max_length=400, label='Description', help_text='Write a few lines about this feature', classname='block_content_field') icon = IconChoiceBlock( required=True, label='Icon', help_text= 'Pick an icon (see https://material.io/tools/icons/) for a bullet point', classname='block_content_field') more_info_url = URLBlock( required=False, label='URL', help_text='A link to be followed for more information', classname='block_content_field') class Meta: template = 'blocks/section_feature_item.html' icon = 'tick-inverse' label = 'Add Feature'
class ImageBackerBlock(StructBlock): name = CharBlock() image = ImageChooserBlock(required=False) url = URLBlock(required=False) class Meta: template = "blog/blocks/image_backer.html"
class FaqBlock(StructBlock): question = CharBlock( required=True, max_length=80, label='Question', help_text="Add a simply worded question, like 'How much will it cost?'" ) answer = TextBlock( required=True, label='Answer', help_text='Provide a short answer in no more than a few lines of text') icon = IconChoiceBlock( required=True, label='Icon', help_text= 'Pick an icon (see https://material.io/tools/icons/) for a bullet point' ) more_info_url = URLBlock( required=False, label='URL', help_text= 'Add a link to be followed for more information on that question, feature or product' ) class Meta: icon = 'help' label = 'FAQ'
class ButtonBlock(StructBlock): url = URLBlock(required=True) text = CharBlock(required=True) class Meta: icon = "fa-mouse" template = "blocks/button_block.html"
class TeasertextBlock(StructBlock): headline = CharBlock(required=True, length=256) text = TextBlock(required=True) link = PageChooserBlock(required=False) externlink = URLBlock(label=_("External Link"), required=False, help_text=_("The external link overwrites the " "link to a local page. It also " "requires a link text.")) link_text = CharBlock(required=False, help_text=_( "Text to be displayed on the link-button." "Should be quite short! If not given, the " "title of the linked page will be used.")) class Meta: template = 'cms_home/blocks/teasertext_block.html' def clean(self, value): result = super().clean(value) errors = {} if value['externlink'] and not value['link_text']: errors['link_text'] = ErrorList([ 'External links require a link text.', ]) if errors: raise ValidationError(_('External links require a link text.'), params=errors) return result
class RichtextLinkBlock(StructBlock): body = RichTextBlock(required=True) link = URLBlock(required=False) link_text = CharBlock(required=False) class Meta: template = 'cms_home/blocks/richtext_with_link.html'
class CardBlock(StructBlock): """Карточки с изображением, текстом и кнопкой.""" title = CharBlock(required=True, help_text="Add your title") cards = ListBlock( StructBlock( [ ("image", ImageChooserBlock(required=True)), ("title", CharBlock(required=True, max_length=40)), ("text", TextBlock(required=True, max_length=200)), ("button_page", PageChooserBlock(required=False)), ( "button_url", URLBlock( required=False, help_text="Если выбрана страница кнопки выше, она будет использоваться первой.", # noqa ), ), ] ) ) class Meta: # noqa template = "layouts/card_block.html" icon = "placeholder" label = "Карточка с фото"
class HomePageCardBlock(StructBlock): page = PageChooserBlock(required=False) url = URLBlock(required=False) content = RichTextBlock() class Meta: template = 'blog/blocks/home_page_card_block.html' help_text = 'One of Page or Url is required'
class ActionLinkBlock(FlattenValueContext, StructBlock): text = CharBlock(label="Link text", required=True) external_url = URLBlock(label="URL", required=True) new_window = BooleanBlock(required=False, label="Open in new window") class Meta: template = 'wagtailnhsukfrontend/action_link.html'
class SingleImg(StructBlock): image = ImageChooserBlock(_('Image')) url = URLBlock(label=_('URL'), required=False) caption = CharBlock(label=_('Caption'), required=False) class Meta: label = _('Single Image') template = 'blog/streamblocks/single_image.html'
class LinkBlock(StructBlock): external_url = URLBlock(label='Ekstern lenke', required=False) page_link = PageChooserBlock(label='Intern lenke', required=False) document = DocumentChooserBlock(label='Dokument- lenke', required=False) class Meta: abstract = True help_text = 'Velg kun èn lenke-type (ekstern/intern/dokument).'
class LinkedButtonBlock(StructBlock): name = CharBlock() url = URLBlock() #Could add hex colour codes + image selection in the future class Meta(): template = "home/blocks/LinkedButtonBlock.html"
class DataSetMixin(models.Model): class Meta(): abstract = True parent_page_types = ['datasection.DataSetListing'] subpage_types = [] release_date = models.DateField(default=datetime.now) authors = StreamField( [('internal_author', PageChooserBlock(required=False, target_model='ourteam.TeamMemberPage', icon='fa-user')), ('external_author', StructBlock([('name', CharBlock(required=False)), ('title', CharBlock(required=False)), ('photograph', ImageChooserBlock(required=False)), ('page', URLBlock(required=False))], icon='fa-user'))], blank=True) meta_data = StreamField( [ ('description', RichTextBlock(required=True, features=RICHTEXT_FEATURES_NO_FOOTNOTES)), ('provenance', RichTextBlock(required=False, features=RICHTEXT_FEATURES_NO_FOOTNOTES)), ('variables', RichTextBlock(required=False, features=RICHTEXT_FEATURES_NO_FOOTNOTES)), ('geography', RichTextBlock(required=False, features=RICHTEXT_FEATURES_NO_FOOTNOTES)), ('geograpic_coding', RichTextBlock(required=False, features=RICHTEXT_FEATURES_NO_FOOTNOTES)), ('unit', RichTextBlock(required=False, features=RICHTEXT_FEATURES_NO_FOOTNOTES)), ('internal_notes', RichTextBlock(required=False, features=RICHTEXT_FEATURES_NO_FOOTNOTES)), ('licence', RichTextBlock(required=False, features=RICHTEXT_FEATURES_NO_FOOTNOTES)), ('citation', RichTextBlock(required=False, template="blocks/urlize_richtext.html", features=RICHTEXT_FEATURES_NO_FOOTNOTES)), ], verbose_name='Content', help_text= 'A description is expected, but only one of each shall be shown') other_pages_heading = models.CharField(blank=True, max_length=255, verbose_name='Heading', default='More about')
class QuickLinkBlock(StructBlock): text = CharBlock(label='link text', required=True) page = PageChooserBlock(label='page', required=False) external_url = URLBlock(label='external URL', required=False) class Meta: template: 'blog/blocks/quick_link_block.html' icon = 'site' value_class = LinkStructValue
class HomePageBlock(StructBlock): url = URLBlock(required=False) page = PageChooserBlock(required=False) title = CharBlock() description = RichTextBlock() class Meta: template = 'cms/blocks/home_page_block.html' help_text = '''
class SlideBlock(StructBlock): title = CharBlock("Title ...", blank=True, max_length=250) classesTitle = CharBlock(label="Title CSS (text-dark etc)", required=False, blank=True) caption = TextBlock(required=False, blank=True) classesCaption = CharBlock(label="Caption CSS (text-danger)", required=False, blank=True) classes = CharBlock(label="CSS classes (bg-light or bg-dark)", required=False, blank=True) background = ImageChooserBlock() button = TextBlock(required=False) link = URLBlock(required=False)
class BigTeaserBlock(StructBlock): title = CharBlock(required=True) subtitle = CharBlock(required=False) picture = ImageChooserBlock(required=False) full_width_picture = BooleanBlock(required=False, default=False) text = RichTextBlock(required=False) external_link = URLBlock( required=False, help_text="Will be ignored if an internal link is provided") internal_link = PageChooserBlock( required=False, help_text='If set, this has precedence over the external link.') from_date = DateBlock(required=False) to_date = DateBlock(required=False) class Meta: icon = 'fa fa-list-alt' template = 'blocks/big_teaser_block.html' def __init__(self, wideimage=False, local_blocks=None, **kwargs): super().__init__(local_blocks=local_blocks, **kwargs) self.wideimage = wideimage def get_context(self, value, parent_context=None): context = super(BigTeaserBlock, self).get_context(value, parent_context=parent_context) context['super_title'] = value.get('title') image = value.get('picture') if image: rendition = image.get_rendition('max-800x800') context['image'] = {'url': rendition.url, 'name': image.title} if value.get('internal_link'): context['href'] = value.get('internal_link').url else: context['href'] = value.get('external_link') if context['href']: context['text_right_link'] = True context['text_right_link_text'] = 'Learn more' context.update({ 'title': value.get('subtitle'), 'description': value.get('text'), 'divider': value.get('subtitle') and value.get('text'), 'calendaricon': True, 'full_width_picture': value.get('full_width_picture'), }) if value.get('from_date') and value.get('to_date'): context['date'] = '"{} to {}"'.format( formats.date_format(value.get('from_date'), "SHORT_DATE_FORMAT"), formats.date_format(value.get('to_date'), "SHORT_DATE_FORMAT")) context['wideimage'] = self.wideimage return context
class HomePageFeature(StructBlock): """Block class for flexible home page features.""" title = CharBlock(icon="title", classname="title", help_text="Feature title.") description = RichTextBlock() image = ImageChooserBlock(required=False) button_text = CharBlock(required=False, help_text="Button text.") button_url = URLBlock(required=False, help_text="Button URL.")
class CoronaButtonLinkBlock(StructBlock): button_text = CharBlock(max_lenght=64, required=True) internal_link = ListBlock(PageChooserBlock(), required=False) external_link = URLBlock(required=False) class Meta: template = 'home/corona/blocks/buttonlink.html' icon = 'site' label = 'Button link'
class SplitBannerSectionBlock(StructBlock): orientation = ChoiceBlock( choices=[ ('left', 'Left'), ('right', 'Right'), ], required=True, default='left', help_text='Choose which side of the image the text will appear on.') headline = TextBlock(help_text='Write a title for this section.', required=False) paragraph = RichTextBlock(icon='fa-paragraph', required=False) CTA = StructBlock([ ('text', CharBlock(help_text='What should the button say?', required=False)), ('link', URLBlock(help_text='Where should the button link to?', required=False)), ], help_text='An optional Call to Action button', blank=True) image_or_video = StructBlock( [ ('image', ImageChooserBlock(help_text='Choose a horizontal photo', required=False)), ('link', URLBlock(help_text='A youtube link to a video', required=False)), ], help_text= 'Either upload an image, or link to a video. If both fields are present, the video will take precident', blank=False, required=True) visible = BooleanBlock(default=True, required=False) class Meta: icon = 'fa-object-ungroup' template = 'blocks/split_banner_section.html' help_text = 'A dynamic block with a split red banner background and image'
class BasePromoBlock(FlattenValueContext, StructBlock): url = URLBlock(label="URL", required=True) heading = CharBlock(required=True) description = CharBlock(required=False) content_image = ImageChooserBlock(label="Image", required=False) alt_text = CharBlock(required=False) class Meta: template = 'wagtailnhsukfrontend/promo.html'
class LinkBlock(StructBlock): url = URLBlock(required=False) page = PageChooserBlock(required=False) label = CharBlock() style = LinkStyleChoiceBlock() class Meta: help_text = ''' Use either URL or page, if both are filled in URL takes precedence.''' template = 'cms/blocks/link_block.html'
class ButtonBlock(StructBlock): text = CharBlock(blank=True) classes = CharBlock(blank=True) link = URLBlock(required=False, label="external URL", blank=True) pagelink = PageChooserBlock(required=False, label="internal URL", blank=True) class Meta: template = "streams/button_block.html" icon = 'form' label = 'Individual button'