allow generic pages to have pigs
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
from grapple.models import GraphQLRichText, GraphQLStreamfield
|
||||
from django.db import models
|
||||
from grapple.models import GraphQLRichText, GraphQLStreamfield, GraphQLString
|
||||
from wagtail.admin.panels import FieldPanel
|
||||
from wagtail.fields import RichTextField, StreamField
|
||||
from wagtail.models import Page
|
||||
@ -6,6 +7,7 @@ from wagtail.search import index
|
||||
|
||||
from dnscms.blocks import PageSectionBlock
|
||||
from dnscms.fields import BASE_BLOCKS
|
||||
from dnscms.options import ALL_PIGS
|
||||
|
||||
|
||||
class GenericPage(Page):
|
||||
@ -15,14 +17,28 @@ class GenericPage(Page):
|
||||
lead = RichTextField(features=["link"])
|
||||
body = StreamField(BASE_BLOCKS + [("page_section", PageSectionBlock())])
|
||||
|
||||
PIG_CHOICES = [
|
||||
("", "Ingen"),
|
||||
] + ALL_PIGS
|
||||
|
||||
pig = models.CharField(
|
||||
max_length=32,
|
||||
choices=PIG_CHOICES,
|
||||
default="",
|
||||
blank=True,
|
||||
help_text="Grisen nedi hjørnet.",
|
||||
)
|
||||
|
||||
content_panels = Page.content_panels + [
|
||||
FieldPanel("lead", heading="Ingress"),
|
||||
FieldPanel("body", heading="Innhold"),
|
||||
FieldPanel("pig", heading="Gris"),
|
||||
]
|
||||
|
||||
graphql_fields = [
|
||||
GraphQLRichText("lead"),
|
||||
GraphQLStreamfield("body"),
|
||||
GraphQLString("pig", required=True),
|
||||
]
|
||||
|
||||
search_fields = Page.search_fields + [index.SearchField("lead"), index.SearchField("body")]
|
||||
|
Reference in New Issue
Block a user