add association index and subpages

This commit is contained in:
2024-05-14 23:36:54 +02:00
parent 0237b1a348
commit fd17e2e5a0
9 changed files with 475 additions and 37 deletions

View File

@ -0,0 +1,18 @@
# Generated by Django 5.0.6 on 2024-05-14 21:07
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('associations', '0003_rename_association_associationpage'),
]
operations = [
migrations.RenameField(
model_name='associationpage',
old_name='websiteUrl',
new_name='website_url',
),
]

View File

@ -0,0 +1,20 @@
# Generated by Django 5.0.6 on 2024-05-14 21:13
import wagtail.fields
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('associations', '0004_rename_websiteurl_associationpage_website_url'),
]
operations = [
migrations.AddField(
model_name='associationindex',
name='lead',
field=wagtail.fields.RichTextField(default=''),
preserve_default=False,
),
]

View File

@ -1,7 +1,13 @@
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 StreamField
from wagtail.fields import RichTextField, StreamField
from wagtail.models import Page
@ -9,6 +15,8 @@ class AssociationIndex(Page):
max_count = 1
subpage_types = ["associations.AssociationPage"]
lead = RichTextField(features=["bold", "italic", "link"])
body = StreamField(
[
("paragraph", blocks.RichTextBlock()),
@ -16,7 +24,13 @@ class AssociationIndex(Page):
)
content_panels = Page.content_panels + [
FieldPanel("body"),
FieldPanel("lead", heading="Leder"),
FieldPanel("body", heading="Innhold"),
]
graphql_fields = [
GraphQLRichText("lead"),
GraphQLStreamfield("body"),
]
@ -44,11 +58,18 @@ class AssociationPage(Page):
on_delete=models.SET_NULL,
related_name="+",
)
websiteUrl = models.URLField()
website_url = models.URLField()
content_panels = Page.content_panels + [
FieldPanel("body"),
FieldPanel("logo"),
FieldPanel("association_type", heading="Type"),
FieldPanel("websiteUrl", heading="Nettside"),
FieldPanel("website_url", heading="Nettside"),
]
graphql_fields = [
GraphQLStreamfield("body"),
GraphQLImage("logo"),
GraphQLString("website_url"),
GraphQLString("association_type"),
]