add contact pages and blocks
This commit is contained in:
62
dnscms/contacts/blocks.py
Normal file
62
dnscms/contacts/blocks.py
Normal file
@ -0,0 +1,62 @@
|
||||
from grapple.helpers import register_streamfield_block
|
||||
from grapple.models import GraphQLForeignKey, GraphQLStreamfield, GraphQLString
|
||||
from wagtail import blocks
|
||||
from wagtail.snippets.blocks import SnippetChooserBlock
|
||||
|
||||
|
||||
@register_streamfield_block
|
||||
class ContactEntityBlock(blocks.StructBlock):
|
||||
contact_entity = SnippetChooserBlock("contacts.ContactEntity")
|
||||
|
||||
graphql_fields = [
|
||||
GraphQLForeignKey("contact_entity", "contacts.ContactEntity"),
|
||||
]
|
||||
|
||||
|
||||
@register_streamfield_block
|
||||
class ContactListBlock(blocks.ListBlock):
|
||||
pass
|
||||
|
||||
|
||||
ContactEntityList = ContactListBlock(ContactEntityBlock(), label="Liste med kontaktpunkter")
|
||||
|
||||
|
||||
@register_streamfield_block
|
||||
class ContactSubsectionBlock(blocks.StructBlock):
|
||||
title = blocks.CharBlock(max_length=64, required=True, label="Tittel")
|
||||
text = blocks.RichTextBlock(features=["bold", "italic", "link"])
|
||||
blocks = blocks.StreamBlock(
|
||||
[
|
||||
("contact_entity_list", ContactEntityList),
|
||||
]
|
||||
)
|
||||
|
||||
graphql_fields = [
|
||||
GraphQLString("title", required=True),
|
||||
GraphQLString("text", required=False),
|
||||
GraphQLStreamfield("blocks", required=False),
|
||||
]
|
||||
|
||||
class Meta:
|
||||
icon = "folder-open-1"
|
||||
|
||||
|
||||
@register_streamfield_block
|
||||
class ContactSectionBlock(blocks.StructBlock):
|
||||
title = blocks.CharBlock(max_length=64, required=True, label="Tittel")
|
||||
text = blocks.RichTextBlock(features=["bold", "italic", "link"])
|
||||
blocks = blocks.StreamBlock(
|
||||
[
|
||||
("contact_entity_list", ContactEntityList),
|
||||
("contact_subsection", ContactSubsectionBlock(label="Kontaktunderseksjon")),
|
||||
]
|
||||
)
|
||||
|
||||
graphql_fields = [
|
||||
GraphQLString("title", required=True),
|
||||
GraphQLString("text", required=False),
|
||||
GraphQLStreamfield("blocks", required=False),
|
||||
]
|
||||
|
||||
class Meta:
|
||||
icon = "folder-open-1"
|
Reference in New Issue
Block a user