class FabricationStreamBlock(StreamBlock): title_text_image = TitleTextImageBlock() image_title_text = ImageTitleTextBlock() title_text_imagelist = TitleTextImageListBlock() item_list = ListBlock(TitleAndTextBlock(), icon='list-ul') numbered_item_list = ListBlock(TitleAndTextBlock(), icon='list-ol') paragraph = RichTextBlock(icon="pilcrow") image = ImageChooserBlock() video = EmbedBlock()
class BaseStreamBlock(StreamBlock): heading_block = HeadingBlock() button_block = ButtonBlock() image_block = ImageBlock() accordion_block = AccordionBlock() embed_block = EmbedBlock() unorderd_list_block = ListBlock( (RichTextBlock(label="Unordered list item")), template="blocks/unorderd_list_block.html", icon="list-ul") orderd_list_block = ListBlock((RichTextBlock(label="Ordered list item")), template="blocks/orderd_list_block.html", icon="list-ol") rich_text_block = RichTextBlock() raw_html_block = RawHTMLBlock()
class SupportersBlock(StructBlock): supporters = ListBlock(SupporterBlock) class Meta: icon = 'fa fa-male' template = 'blocks/supporters_block.html' def get_context(self, value, parent_context=None): context = super(SupportersBlock, self).get_context(value, parent_context=parent_context) context['supporters'] = [] for supporter in value.get('supporters'): supp_dict = { 'name': supporter.get('name'), 'text': supporter.get('content') } # for contact in supporter.get('contacts'): # n, w, e = contact.get('name'), contact.get('website'), contact.get('email') # supp_dict['text'] += "<p>{n} <a target='_blank' href='{w}'><i class='fa fa-external-link' aria-hidden='true'></i></a> " \ # "<a target='_blank' href='mailto:{e}'><i class='fa fa-envelope' aria-hidden='true'></i></a></p>".format(n=n, w=w, e=e) try: supp_dict['image'] = { 'url': supporter.get('image').get_rendition( 'fill-500x500-c100').url, 'name': supporter.get('image').title } except: pass context['supporters'] += [supp_dict] return context
class BlogPage(Page): date = models.DateField("Post date") intro = models.CharField(max_length=250) intro_image = models.ForeignKey( 'wagtailimages.Image', null=True, blank=True, on_delete=models.SET_NULL, related_name='+' ) last_modified = models.DateField( "Date article modified", blank=True, auto_now=True ) body = RichTextField(blank=True) slider = StreamField([ ('image', ListBlock(ImageCarouselBlock(), icon="image")), ], blank=True) search_fields = Page.search_fields + [ index.SearchField('intro'), index.SearchField('body'), ] parent_page_types = ['home.HomePage'] content_panels = Page.content_panels + [ FieldPanel('date'), FieldPanel('intro'), ImageChooserPanel('intro_image'), FieldPanel('body', classname="full"), StreamFieldPanel('slider'), ]
class TitleTextImageListBlock(StructBlock): image_list = ListBlock(TitleTextImageBlock()) title = CharBlock() text = RichTextBlock(features=['bold', 'italic', 'ul', 'ol', 'link']) class Meta: template = 'core/blocks/title_text_imagelist.html'
class StatementBlock(StructBlock): title = CharBlock() subtitles = ListBlock(CharBlock(required=False), required=False) call_to_action = ListBlock(CallToActionBlock(), required=False, help_text='Large button to direct user to ' 'specific content. Last element ' 'has greatest emphasis.') signup_form = BooleanBlock(required=False, help_text='Check to display an email ' 'signup form in this frame.') caveats = ListBlock(CharBlock(required=False), required=False) class Meta: icon = 'pilcrow' template = 'blocks/statement.html'
class ProtocolBlock(StructBlock): complete_pdf = DocumentChooserBlock(label='Complete PDF') pdfs = ListBlock(PDFBlock(), label='Chapter PDFs') image = ImageBlock() version = CharBlock() class Meta: icon = 'fa fa-newspaper-o' template = 'blocks/protocol_block.html' def get_context(self, value, parent_context=None): context = super(ProtocolBlock, self).get_context(value, parent_context=parent_context) context['links'] = [] for pdf in value.get('pdfs'): context['links'] += [{ 'fontawesome': 'file-pdf-o', 'href': pdf.get('file').url, 'text': pdf.get('description') }] try: rendition = value.get('image').get_rendition('max-500x500') context['image'] = { 'url': rendition.url, 'name': value.get('image').title } except: pass return context
class ServicePanel(StructBlock): services = ListBlock(Service) title = CharBlock(help_text='title for the block') class Meta: icon = "fa-quote-left" template = "blocks/services_panel.html"
class ProcessPanel(StructBlock): title = CharBlock(help_text='title for the panel') processes = ListBlock(ProcessBlock) class Meta: icon = "fa-quote-left" template = "blocks/process.html"
class DefinitionListBlock(ContentBlock): definitions = ListBlock( StructBlock([('title', CharBlock()), ('definition', CharBlock())])) class Meta: icon = 'tag' template = 'blocks/definition_list.html'
class NavigationSettings(BaseSetting, ClusterableModel): header_links = StreamField([ ('item', OverrideablePageChooserBlock()), ], blank=True) footer_links = StreamField([ ('column', StructBlock([ ('column_heading', TextBlock()), ('subitems', ListBlock(OverrideablePageChooserBlock(label="Sub-item"))), ])), ], blank=True) footer_secondary_links = StreamField([ ('item', OverrideablePageChooserBlock()), ], blank=True) panels = [ StreamFieldPanel('header_links'), StreamFieldPanel('footer_links'), StreamFieldPanel('footer_secondary_links'), ] def save(self, *args, **kwargs): super().save(*args, **kwargs) purge_esi() def delete(self, *args, **kwargs): super().delete(*args, **kwargs) purge_esi()
class HomePage(Page): body = StreamField([('carousel', ListBlock(CarouselFrame(), icon='cogs', template='blocks/carousel.html', help_text='A horizontal ' 'scrolling set ' 'of images with text ' 'overlaid.')), ('short_hero', ShortHeroBlock()), ('section', SectionBlock()), ('quotations', QuotationsBlock()), ('stats', StatsBlock()), ('statement', StatementBlock()), ('team_carousel', ListBlock(TeamMemberBlock(), icon='group', template='blocks/' 'team_carousel.' 'html')), ('soundcloud', SoundCloudBlock()), ('section_carousel', ListBlock(ImageChooserBlock(), icon='image', template='blocks/' 'section_' 'carousel' '.html')), ('content_carousel', ListBlock(ContentCarouselFrame(), icon='image', template='blocks/' 'content_' 'carousel' '.html'))], blank=True) search_image = models.ForeignKey('wagtailimages.Image', null=True, blank=True, on_delete=models.SET_NULL, related_name='+') social_image = models.ForeignKey('wagtailimages.Image', null=True, blank=True, on_delete=models.SET_NULL, related_name='+')
class CounterPanel(StructBlock): title = CharBlock() subtitle = CharBlock() counters = ListBlock(CounterBlock) class Meta: icon = "title" template = "blocks/counter_panel.html"
class PapersBlock(StructBlock): see_all_offset = IntegerBlock(default=8, help_text='Show "See all" after x entries.') papers = ListBlock(PaperBlock) class Meta: icon = 'fa fa-file-text' template = 'blocks/outcomes_block.html'
class WhyChooseUsSectionBlock(StructBlock): headline = CharBlock(label='Заголовок секции', ) text = TextBlock(label='Текст') cards = ListBlock(_WhyChoseUsBlock, label='Список карточек', max_num=4) class Meta: min_num = 1 max_num = 1 template = 'home/blocks/why_choose_us_section_block.html'
class DiseaseSectionBlock(StructBlock): headline = CharBlock(label='Заголовок секции', ) text = TextBlock(label='Текст') diseases = ListBlock(_SingleDiseaseBlock, label='Список заболеваний') class Meta: min_num = 1 max_num = 1 template = 'home/blocks/disease_section_block.html'
class InstitutionsBlock(StructBlock): block_heading = CharBlock(required=True) items = ListBlock( SnippetChooserBlock(target_model=Institution, required=True)) class Meta: image = 'pages/images/streamfield_blocks/institutions.jpg' template = 'pages/streamfield_blocks/institutions.html'
class OrderedListBlock(StructBlock): title = CharBlock(required=False) items = ListBlock( StructBlock([('title', CharBlock()), ('description', TextBlock())])) label = CharBlock(required=False) page = PageChooserBlock(required=False) class Meta: template = 'cms/blocks/ordered_list_block.html'
class TopicGridBlock(StructBlock): block_heading = CharBlock(required=True) larger_images = BooleanBlock(default=False, required=False) items = ListBlock(PageChooserBlock(target_model='topics.TopicIndexPage')) read_more_button = ReadMoreButtonBlock(required=False) class Meta: image = 'pages/images/streamfield_blocks/topic_grid.jpg' template = 'pages/streamfield_blocks/topic_grid.html'
class SkillbarBlock(ContentBlock): skills = ListBlock( StructBlock([('skill_percentage', CharBlock()), ('skill_name', CharBlock())])) class Meta: icon = 'form' template = 'blocks/skillbar.html'
class FeaturedPageBlock(StructBlock): title = CharBlock(required=False) starred_page = PageChooserBlock(required=False, help_text=''' Leave this blank to randomise the starred item from the items below.''') items = ListBlock(PageChooserBlock(), required=False) class Meta: template = 'cms/blocks/featured_page_block.html'
class TeamMemberBlock(StructBlock): name = CharBlock() title = CharBlock(required=False) qualifications = CharBlock(required=False) image = ImageChooserBlock() links = ListBlock(LinkBlock(), required=False) class Meta: icon = 'user' template = 'blocks/team_member.html'
class ImageListBlock(StructBlock): title = CharBlock(required=False) items = ListBlock( StructBlock([('title', CharBlock()), ('subtitle', CharBlock()), ('description', RichTextBlock()), ('image', ImageChooserBlock()), ('page', PageChooserBlock(required=False))])) class Meta: template = 'cms/blocks/image_list_block.html'
class AccordionBlock(StructBlock): class Meta: icon = "arrow-down-big" template = "blocks/accordion_block.html" accordion_group_title = TextBlock(required=False, blank=True, default="") accordion_items = ListBlock( StructBlock([ ('accordion_title', CharBlock(required=True)), ('accordion_content', RichTextBlock(required=True)), ]))
class VisualizationGroupBlock(StructBlock): visualizations = ListBlock(VisualizationBlock) class Meta: template = 'builder/blocks/visualization.html' def render(self, value): # Iterate through vis blocks and grab variable dimensions. # Validate that they have a common dimension, and then pass # the union of their dimensions to the VisGroup react component. return super(VisualizationGroupBlock, self).render(value)
class GalleriesPage(Page): body = StreamField([ ('image', ListBlock(ImageBlock(), template='blocks/galleries.html')), ], blank=True, null=True) content_panels = Page.content_panels + [StreamFieldPanel('body')] template = 'home/default_page.html' parent_page_types = ['EventListPage'] subpage_types = []
class ImageGridBlock(StructBlock): title = CharBlock(required=False) items = ListBlock( StructBlock([('image', ImageChooserBlock()), ('url', URLBlock(required=False)), ('page', PageChooserBlock(required=False))])) class Meta: help_text = ''' Use either URL or page, if both are filled in URL takes precedence.''' template = 'cms/blocks/image_grid_block.html'
class SidebarCallOutBlock(StructBlock): title = CharBlock() body = RichTextBlock(required=False) icon = CharBlock(required=False, help_text='Text block passed as the icon selected. ' 'Choose between Ionic Icons or FontAwesome.') links = ListBlock(LinkBlock(), required=False) class Meta: icon = 'radio-empty' template = 'blocks/sidebar_callout.html'
class SelectedMethodsSection(StructBlock): headline = CharBlock(label='Заголовок секции', ) text = TextBlock(label='Текст') selected_methods = ListBlock( _MethodBlock, label='Методики', min_num=3, max_num=3, ) class Meta: template = 'home/blocks/selected_methods_section_block.html'
class ImageGrid(StructBlock): images = ListBlock(ImageGridItem()) # width = WidthChoiceBlock(required=True, default="width-100") width = ChoiceBlock(choices=[ ('width-100', '100% stretched'), ('width-150', '150% stretched'), ('width-50', '50% stretched') ], default='width-100', label='Grid width') class Meta: template = 'base/image_grid_block.html' form_classname = "fieldname-image_grid"