76 lines
1.9 KiB
Python
76 lines
1.9 KiB
Python
from django.db import models
|
|
from grapple.models import (
|
|
GraphQLImage,
|
|
GraphQLRichText,
|
|
GraphQLStreamfield,
|
|
GraphQLString,
|
|
)
|
|
from wagtail import blocks
|
|
from wagtail.admin.panels import FieldPanel
|
|
from wagtail.fields import RichTextField, StreamField
|
|
from wagtail.models import Page
|
|
|
|
|
|
class AssociationIndex(Page):
|
|
max_count = 1
|
|
subpage_types = ["associations.AssociationPage"]
|
|
|
|
lead = RichTextField(features=["bold", "italic", "link"])
|
|
|
|
body = StreamField(
|
|
[
|
|
("paragraph", blocks.RichTextBlock()),
|
|
]
|
|
)
|
|
|
|
content_panels = Page.content_panels + [
|
|
FieldPanel("lead", heading="Leder"),
|
|
FieldPanel("body", heading="Innhold"),
|
|
]
|
|
|
|
graphql_fields = [
|
|
GraphQLRichText("lead"),
|
|
GraphQLStreamfield("body"),
|
|
]
|
|
|
|
|
|
class AssociationPage(Page):
|
|
subpage_types = []
|
|
parent_page_types = ["associations.AssociationIndex"]
|
|
show_in_menus = False
|
|
|
|
class AssociationType(models.TextChoices):
|
|
FORENING = "forening", "Forening"
|
|
UTVALG = "utvalg", "Utvalg"
|
|
|
|
body = StreamField(
|
|
[
|
|
("paragraph", blocks.RichTextBlock()),
|
|
]
|
|
)
|
|
association_type = models.CharField(
|
|
max_length=64, choices=AssociationType, default=AssociationType.FORENING
|
|
)
|
|
logo = models.ForeignKey(
|
|
"wagtailimages.Image",
|
|
null=True,
|
|
blank=True,
|
|
on_delete=models.SET_NULL,
|
|
related_name="+",
|
|
)
|
|
website_url = models.URLField()
|
|
|
|
content_panels = Page.content_panels + [
|
|
FieldPanel("body"),
|
|
FieldPanel("logo"),
|
|
FieldPanel("association_type", heading="Type"),
|
|
FieldPanel("website_url", heading="Nettside"),
|
|
]
|
|
|
|
graphql_fields = [
|
|
GraphQLStreamfield("body"),
|
|
GraphQLImage("logo"),
|
|
GraphQLString("website_url"),
|
|
GraphQLString("association_type"),
|
|
]
|