class BaseSection(Page): """ BaseSection abstract base class. All sections should inherit from this class.This Will Also Serve As A Regular Page As Well. """ page_icon = StreamField( StreamBlock([('icon_page', ImageMapBlock())], min_num=0, max_num=1)) parent_page_types = [] #empty by default subpage_types = [] section_template_name = "" #default empty section_slug = AutoSlugField(populate_from=['title'], editable=True) int_order = models.IntegerField(default=170) banner_image = models.ForeignKey('wagtailimages.Image', null=True, on_delete=models.SET_NULL, related_name='+', blank=True) ## promote_panels = [ MultiFieldPanel(Page.promote_panels, "Page Configuration Base-Section"), ] ## page_panel_options = [ StreamFieldPanel('page_icon'), FieldPanel('section_slug'), ImageChooserPanel('banner_image'), ] content_panels = Page.content_panels + [] main_content_panels = [] para_list = [] @cached_classmethod def get_edit_handler(cls): edit_handler = TabbedInterface([ ObjectList(cls.content_panels, heading='Snippet Content'), ObjectList(cls.main_content_panels, heading='Main Content'), ObjectList(cls.page_panel_options, heading='Page Options'), ObjectList(cls.promote_panels, heading='Promote'), ObjectList(cls.settings_panels, heading='Settings', classname="settings"), ]) return edit_handler.bind_to(cls) class Meta: abstract = True def getSectionLinkWithHash(self): return "#{}".format(self.section_slug) def getSectionLink(self): return "{}".format(self.section_slug) def getSectionHTML(self): if self.section_template_name: return 1 else: return 2
class TestPage(Page): template = 'page.html' body = StreamField([ ('heading', blocks.CharBlock(classname="full title")), ('paragraph', blocks.RichTextBlock()), ('imagemap', ImageMapBlock()), ]) content_panels = Page.content_panels + [ StreamFieldPanel('body'), ]
from wagtail.wagtailcore import blocks from wagtail.wagtailcore.fields import StreamField from wagtail.wagtailcore.models import Orderable, Page from wagtail.wagtaildocs.edit_handlers import DocumentChooserPanel from wagtail.wagtailimages.blocks import ImageChooserBlock from wagtail.wagtailsearch import index from wagtail_svgmap.blocks import ImageMapBlock from digihel.mixins import RelativeURLMixin rich_text_blocks = [ ('heading', blocks.CharBlock(classname="full title")), ('paragraph', blocks.RichTextBlock()), ('image', ImageChooserBlock()), ('table', TableBlock()), ('image_map', ImageMapBlock()), ] class TwoColumnBlock(blocks.StructBlock): left_column = blocks.StreamBlock(rich_text_blocks, icon='arrow-left', label=_('Left column content')) right_column = blocks.StreamBlock(rich_text_blocks, icon='arrow-right', label=_('Right column content')) class Meta: icon = 'placeholder' label = _('Two columns') template = 'content/blocks/two_column.html'
class CustomSVGImageBlock(blocks.StructBlock): svg_image = ImageMapBlock(required=True) class_name = blocks.CharBlock(required=False) description = blocks.CharBlock(required=False)