add support for page sections on generic pages
This commit is contained in:
@@ -136,3 +136,50 @@ class FeaturedBlock(blocks.StructBlock):
|
||||
|
||||
class Meta:
|
||||
icon = "arrow-right-full"
|
||||
|
||||
|
||||
class PageSectionNavigationBlock(blocks.StaticBlock):
|
||||
class Meta:
|
||||
icon = "order-down"
|
||||
label = "Sideseksjonsnavigasjon"
|
||||
admin_text = "Lager automatisk ankerlenker til alle sideseksjoner"
|
||||
|
||||
|
||||
BASE_BLOCKS = [
|
||||
("paragraph", blocks.RichTextBlock(label="Rik tekst")),
|
||||
("image", ImageWithTextBlock(label="Bilde")),
|
||||
("image_slider", ImageSliderBlock(label="Bildegalleri")),
|
||||
("horizontal_rule", HorizontalRuleBlock(label="Skillelinje")),
|
||||
("featured", FeaturedBlock(label="Fremhevet underside")),
|
||||
("page_section_navigation", PageSectionNavigationBlock()),
|
||||
]
|
||||
|
||||
|
||||
@register_streamfield_block
|
||||
class PageSectionBlock(blocks.StructBlock):
|
||||
COLOR_CHOICES = (
|
||||
("deepBrick", "Dyp tegl"),
|
||||
("neufPink", "Griserosa"),
|
||||
("goldenOrange", "Gyllen oransje"),
|
||||
("goldenBeige", "Gyllen beige"),
|
||||
("chateauBlue", "Slottsblå"),
|
||||
)
|
||||
|
||||
title = blocks.CharBlock(max_length=64, required=True, label="Tittel")
|
||||
background_color = blocks.ChoiceBlock(
|
||||
label="Bakgrunnsfarge",
|
||||
required=False,
|
||||
choices=COLOR_CHOICES,
|
||||
)
|
||||
body = blocks.StreamBlock(
|
||||
[block for block in BASE_BLOCKS if block[0] != "page_section_navigation"]
|
||||
)
|
||||
|
||||
graphql_fields = [
|
||||
GraphQLString("title", required=True),
|
||||
GraphQLString("background_color", required=False),
|
||||
GraphQLStreamfield("body", required=True),
|
||||
]
|
||||
|
||||
class Meta:
|
||||
icon = "folder-open-1"
|
||||
|
||||
@@ -1,15 +1,8 @@
|
||||
from wagtail import blocks
|
||||
from wagtail.fields import StreamField
|
||||
|
||||
from dnscms.blocks import FeaturedBlock, HorizontalRuleBlock, ImageSliderBlock, ImageWithTextBlock
|
||||
from dnscms.blocks import BASE_BLOCKS
|
||||
|
||||
CommonStreamField = StreamField(
|
||||
[
|
||||
("paragraph", blocks.RichTextBlock(label="Rik tekst")),
|
||||
("image", ImageWithTextBlock(label="Bilde")),
|
||||
("image_slider", ImageSliderBlock(label="Bildegalleri")),
|
||||
("horizontal_rule", HorizontalRuleBlock(label="Skillelinje")),
|
||||
("featured", FeaturedBlock(label="Fremhevet underside")),
|
||||
],
|
||||
BASE_BLOCKS,
|
||||
default=[("paragraph", "")],
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user