class RNDBlock(blocks.StructBlock): background_image = ImageChooserBlock() headline = blocks.CharBlock() body = blocks.CharBlock() tiles = blocks.ListBlock(blocks.StructBlock([ ('value', blocks.CharBlock()), ('description', blocks.CharBlock()), ])) class Meta: template = 'main/blocks/rnd.html'
class JobBlock(blocks.StructBlock): job = blocks.ListBlock( blocks.StructBlock([ ("title", blocks.CharBlock(required=True, max_length=100)), ("category", blocks.CharBlock(required=True, max_length=50)), ])) class Meta: template = "streams/job_block.html" icon = "doc-full" label = "Job"
class BrandsBlock(blocks.StructBlock): title = blocks.CharBlock(required=True) # Name changed to avoid conflicts with previous revisions of pages brands2 = blocks.ListBlock( blocks.StructBlock([("url", blocks.URLBlock(required=False)), ("image", ImageChooserBlock())])) class Meta: icon = "pick" template = "core/blocks/brands_block.html"
class LevelBlock(blocks.StructBlock): title = blocks.CharBlock(required=False) tiles = blocks.ListBlock( blocks.StructBlock([ ('icon', ImageChooserBlock(required=False)), ('value', blocks.CharBlock()), ('property_name', blocks.CharBlock(required=False)), ])) class Meta: template = 'main/blocks/level.html'
class ColumnWideImageBlock(blocks.StructBlock): cards = blocks.ListBlock( blocks.StructBlock([ ("image", ImageChooserBlock(required=True)), ])) class Meta: template = "streams/column_wide_image.html" icon = "image" label = "Column Wide Image Block"
class TestimonialsBlock(blocks.StreamBlock): testimonial = blocks.StructBlock([ ('testimonial', blocks.TextBlock(icon='help', label='Testimonial')), ('client', RichTextBlock(icon='edit', label='Client')), ], icon='help') class Meta: template = "blocks/testimonials_block.html" icon = "openquote" label = "Testimonials Slider"
class FAQBlock(blocks.StreamBlock): faq = blocks.StructBlock([ ('question', blocks.TextBlock(icon='help', label='FAQ Question')), ('answer', RichTextBlock(icon='edit', label='FAQ Answer')), ], icon='help') class Meta: template = "blocks/faq_block.html" icon = "help" label = "FAQ Dropdown"
def get_form_block(self): return blocks.StructBlock([ ('label', blocks.CharBlock()), ('help_text', blocks.CharBlock(required=False)), ('required', blocks.BooleanBlock(required=False)), ('regex', blocks.ChoiceBlock(choices=self.get_regex_choices())), ('error_message', blocks.CharBlock()), ('default_value', blocks.CharBlock(required=False)), ], icon=self.icon, label=self.label)
class TileGridSpacedBlock(blocks.StructBlock): title = blocks.CharBlock() tiles = blocks.ListBlock(blocks.StructBlock([ ('image', ImageChooserBlock()), ('title', blocks.CharBlock(required=False)), ('subtitle', blocks.CharBlock(required=False)), ('body', blocks.RichTextBlock(features=settings.RICHTEXT_INLINE_FEATURES)), ])) class Meta: template = 'main/blocks/tile_grid_spaced.html'
class ColumnOptions(blocks.StructBlock): column_options = blocks.StructBlock([ ('classes', blocks.CharBlock(required=False, max_length=255, help_text="Apply custom classes to this column.")), ]) content = blocks.RichTextBlock(required=False, classname="column-content") class Meta: form_classname = "column-options"
class HomePage(Page): body = StreamField([ ('text', blocks.RichTextBlock()), ('image', ImageChooserBlock()), ('action', blocks.StructBlock([ ('heading1', blocks.CharBlock()), ('heading2', blocks.CharBlock()), ('text1', blocks.RichTextBlock()), ('text2', blocks.RichTextBlock()), ('page1', blocks.PageChooserBlock()), ('page2', blocks.PageChooserBlock()), ], template='home/blocks/action.html')), ('action_register', blocks.StructBlock([('text', blocks.RichTextBlock())], template='home/blocks/action_register.html')), ]) content_panels = Page.content_panels + [ StreamFieldPanel('body'), ] def serve(self, request): # user = request.user # if user.is_authenticated: # feed = feed_manager.get_feed('timeline', user.id) # else: # feed = feed_manager.get_feed('timeline', 0) # enricher = Enrich() # timeline = enricher.enrich_activities(feed.get(limit=25)['results']) return render( request, 'home/home_page.html', { 'page': self, # 'timeline': timeline, })
class CarouselImages(blocks.StructBlock): """Betwen 1 and 5 imagefor home page carousel.""" images = blocks.ListBlock( blocks.StructBlock([ ("carousel_image", ImageChooserBlock(required=False)), ])) class Meta: template = "patterns/molecules/streams/carousel-image.html" icon = "placeholder" label = "Image carousel Block"
class HorizontalGallery(blocks.StructBlock): """Image row.""" images = blocks.ListBlock( blocks.StructBlock([ ("img", ImageChooserBlock()), ], icon="image")) class Meta: label = "Horizontal Gallery" template = "streams/horizontal_gallery.html" icon = "image"
class TeamBlock(blocks.StructBlock): team = blocks.ListBlock( blocks.StructBlock([ ("image", ImageChooserBlock(required=True)), ("name", blocks.CharBlock(required=True, max_length=50)), ("role", blocks.CharBlock(required=True, max_length=100)), ])) class Meta: template = "streams/team_block.html" icon = "user" label = "Team"
def get_form_block(self): return blocks.StructBlock( [ ("label", blocks.CharBlock()), ("help_text", blocks.CharBlock(required=False)), ("required", blocks.BooleanBlock(required=False)), ("choices", blocks.ListBlock( blocks.CharBlock(label="Option"))), ], icon=self.icon, label=self.label, )
class HeroSwitchBlock(blocks.StructBlock): headline = blocks.CharBlock() tiles = blocks.ListBlock( blocks.StructBlock([ ('background_image', ImageChooserBlock()), ('title', blocks.CharBlock()), ('page', blocks.PageChooserBlock()), ('side_image', ImageChooserBlock(required=False)), ]), ) class Meta: template = 'main/blocks/hero_switch.html'
class HeroProcessBlock(blocks.StructBlock): background_image = ImageChooserBlock() title = blocks.CharBlock(required=False) headline = blocks.CharBlock(required=False) body = blocks.RichTextBlock(required=False, features=settings.RICHTEXT_INLINE_FEATURES) tiles = blocks.ListBlock(blocks.StructBlock([ ('icon', ImageChooserBlock()), ('text', blocks.RichTextBlock(features=settings.RICHTEXT_INLINE_FEATURES)), ])) class Meta: template = 'main/blocks/hero_process.html'
class LogosBlock(blocks.StructBlock): logos = blocks.ListBlock( blocks.StructBlock([('image', ImageChooserBlock()), ('link', blocks.URLBlock(required=False)), ('description', blocks.CharBlock(required=False)) ])) class Meta: label = _('Logos') icon = 'fa-pied-piper' template = 'blocks/logos.html' group = _('Content')
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 BootstrapGrayscaleFeaturedSmallRowBlock(blocks.StructBlock): item = blocks.ListBlock(blocks.StructBlock([ ('heading', blocks.CharBlock(required=False)), ('paragraph', blocks.RichTextBlock(required=False)), ('image', ImageChooserBlock()), ('image_position', blocks.ChoiceBlock(choices=(('left', 'Left'), ('right', 'Right')))) ])) class Meta: app_label = 'bootstrap_grayscale' template = 'bootstrap_grayscale/blocks/featured/grayscale_featured_small_row_block.html' label = 'Featured Small Row'
class ImageSlider(blocks.StructBlock): """A slider of images using tiny slider""" slides = blocks.ListBlock( blocks.StructBlock([ ("image", ImageChooserBlock(required=False)), ])) class Meta: icon = 'fa-object-ungroup' template = 'wagtail_block_collection/media/slider_block.html' group = "Media" label = "IMG Slider"
class CarouselSlider(blocks.StructBlock): id = blocks.CharBlock( required=True, help_text="A unique name that can not contain spaces") slides = blocks.ListBlock( blocks.StructBlock([("image", ImageChooserBlock(required=True)), ("title", blocks.CharBlock(required=False)), ("subline", blocks.CharBlock(required=False))])) class Meta: icon = 'fa-object-ungroup' template = 'wagtail_block_collection/sections/carousel_slider_section.html' label = "IMG Slider"
class ProjectBlock(blocks.StructBlock): project = blocks.ListBlock( blocks.StructBlock([ ("image", ImageChooserBlock(required=True)), ("client", blocks.CharBlock(required=True, max_length=30)), ("link", PageChooserBlock(required=True)), ])) class Meta: template = "streams/project_block.html" icon = "folder" label = "Project"
class PodcastPage(FixUrlMixin, Page): title_en = models.CharField( verbose_name=_("title"), max_length=255, blank=False, help_text=_("The page title as you'd like it to be seen by the public"), ) title_translated = TranslatedField("title", "title_en") description_sk = RichTextField(blank=True) description_en = RichTextField(blank=True) description = TranslatedField("description_sk", "description_en") episodes = StreamField( [ ( "episode", blocks.StructBlock( [ ("number", blocks.IntegerBlock(min_value=1)), ("title_sk", blocks.CharBlock()), ("title_en", blocks.CharBlock()), ("category", SnippetChooserBlock("home.Category")), ("url_anchor", blocks.URLBlock()), ("url_apple", blocks.URLBlock()), ("url_spotify", blocks.URLBlock()), ] ), ), ] ) content_panels = [ FieldPanel("title", classname="full title", heading="Title SK"), FieldPanel("title_en", classname="full title", heading="Title EN"), FieldPanel("description_sk", classname="full"), FieldPanel("description_en", classname="full"), ] episodes_panel = [ StreamFieldPanel("episodes"), ] edit_handler = TabbedInterface( [ ObjectList(content_panels, heading=_("Content")), ObjectList(episodes_panel, heading=_("Episodes")), ObjectList(Page.promote_panels, heading="Promote"), ObjectList(Page.settings_panels, heading="Settings", classname="settings"), ] ) def get_context(self, request, *args, **kwargs): context = super().get_context(request, *args, **kwargs) context["header_festival"] = last_festival(self) return context
class AgendaItemBlock(blocks.StructBlock): """Content for an event agenda item""" start_time = blocks.TimeBlock() end_time = blocks.TimeBlock(required=False) title = blocks.CharBlock() speaker = blocks.PageChooserBlock(required=False, page_type="people.Person") external_speaker = blocks.StructBlock([ ("name", blocks.CharBlock(required=False)), ("url", blocks.URLBlock(label="URL", required=False)), ])
class Migration(migrations.Migration): dependencies = [ ('testapp', '0002_nested_stream_block_page'), ] operations = [ migrations.AlterField( model_name='singlestreamfieldpage', name='content', field=core_fields.StreamField( [('atom', core_blocks.StructBlock([('title', core_blocks.CharBlock()) ])), ('molecule', core_blocks.StructBlock( [('title', core_blocks.CharBlock()), ('atoms', core_blocks.ListBlock( core_blocks.StructBlock( [('title', core_blocks.CharBlock())])))])), ('organism', core_blocks.StructBlock( [('molecules', core_blocks.ListBlock( core_blocks.StructBlock( [('title', core_blocks.CharBlock()), ('atoms', core_blocks.ListBlock( core_blocks.StructBlock([ ('title', core_blocks.CharBlock()) ])))])))]))], blank=True), ), ]
class HomePage(DiscoverUniBasePage): header = TextField(blank=True) intro = RichTextField(blank=True) informational_title = TextField(blank=True) informational_text = TextField(blank=True) informational_text_link = TextField(blank=True) course_wizard_link = TextField(blank=True) box_1_title = TextField(blank=True) box_1_content = TextField(blank=True) box_1_link = TextField(blank=True) box_2_title = TextField(blank=True) box_2_content = TextField(blank=True) box_2_link = TextField(blank=True) box_3_link = TextField(blank=True) page_links = StreamField([ ('link', blocks.StructBlock([ ('page', blocks.PageChooserBlock()), ('title', blocks.CharBlock()) ])) ]) content_panels = DiscoverUniBasePage.content_panels + [ FieldPanel('header', classname="full"), FieldPanel('intro', classname="full"), FieldPanel('informational_title', classname="full"), FieldPanel('informational_text', classname="full"), FieldPanel('informational_text_link', classname="full"), FieldPanel('course_wizard_link', classname="full"), FieldPanel('box_1_title', classname="full"), FieldPanel('box_1_content', classname="full"), FieldPanel('box_1_link', classname="full"), FieldPanel('box_2_title', classname="full"), FieldPanel('box_2_content', classname="full"), FieldPanel('box_2_link', classname="full"), FieldPanel('box_3_link', classname="full"), StreamFieldPanel('page_links', classname="full"), ] def get_context(self, request): context = super().get_context(request) language = self.get_language() context['institutions_list'] = InstitutionList.get_options()[language] context['language'] = language context['search_info'] = { 'institutions': "", 'number_options_selected': translations.term_for_key('number_options_selected', language), 'institution_name': translations.term_for_key('institution_name', language), 'select_all_results': translations.term_for_key('select_all_results', language), 'select_all_institutions': translations.term_for_key('select_all_institutions', language) } return context
class BannerBlock(blocks.StructBlock): banners = blocks.ListBlock( blocks.StructBlock([ ('image', ImageChooserBlock()), ('mobile_image', ImageChooserBlock()), ('link', blocks.URLBlock()), ])) loop_time = blocks.IntegerBlock(default=3000) class Meta: label = 'Banner' template = 'home/blocks/banner.html' icon = 'user'
class Migration(migrations.Migration): dependencies = [ ('mega_menu', '0001_initial'), ] operations = [ migrations.AlterField( model_name='menu', name='submenus', field=core_fields.StreamField((('submenu', core_blocks.StructBlock((('title', core_blocks.CharBlock()), ('overview_page', core_blocks.PageChooserBlock(required=False)), ('featured_links', core_blocks.ListBlock(core_blocks.StructBlock((('page', core_blocks.PageChooserBlock(required=False)), ('text', core_blocks.CharBlock(required=False)), ('url', core_blocks.CharBlock(required=False)))), default=[])), ('other_links', core_blocks.ListBlock(core_blocks.StructBlock((('page', core_blocks.PageChooserBlock(required=False)), ('text', core_blocks.CharBlock(required=False)), ('url', core_blocks.CharBlock(required=False)), ('icon', core_blocks.CharBlock()))), default=[])), ('columns', core_blocks.ListBlock(core_blocks.StructBlock((('heading', core_blocks.CharBlock(required=False)), ('links', core_blocks.ListBlock(core_blocks.StructBlock((('page', core_blocks.PageChooserBlock(required=False)), ('text', core_blocks.CharBlock(required=False)), ('url', core_blocks.CharBlock(required=False)))), default=[])))), default=[]))))),)), ), ]
def get_text_body(raw): if options["splitmessages"] == "yes": struct_blocks = [] if options["newline"]: rows = raw.split(options["newline"]) else: rows = raw.splitlines() for row in rows: if row: block = blocks.StructBlock([ ("message", blocks.TextBlock()), ]) block_value = block.to_python({"message": row}) struct_blocks.append(("Whatsapp_Message", block_value)) return struct_blocks else: if raw: block = blocks.StructBlock([ ("message", blocks.TextBlock()), ]) block_value = block.to_python({"message": raw}) return [("Whatsapp_Message", block_value)]