move featured events from settings to home page
This commit is contained in:
@ -1,15 +1,44 @@
|
||||
from django.db import models
|
||||
|
||||
from wagtail.models import Page
|
||||
from wagtail.fields import StreamField
|
||||
from wagtail import blocks
|
||||
from wagtail.admin.panels import FieldPanel
|
||||
from wagtail.images.blocks import ImageChooserBlock
|
||||
|
||||
|
||||
# https://docs.wagtail.org/en/stable/topics/pages.html
|
||||
# https://docs.wagtail.org/en/stable/reference/streamfield/blocks.html#wagtail.fields.StreamField
|
||||
from grapple.models import (
|
||||
GraphQLCollection,
|
||||
GraphQLForeignKey,
|
||||
)
|
||||
from modelcluster.fields import ParentalKey
|
||||
from modelcluster.models import ClusterableModel
|
||||
from wagtail.admin.panels import (
|
||||
InlinePanel,
|
||||
PageChooserPanel,
|
||||
)
|
||||
from wagtail.models import Orderable, Page
|
||||
|
||||
|
||||
class HomePage(Page):
|
||||
pass
|
||||
max_count = 1
|
||||
subpage_types = []
|
||||
|
||||
content_panels = Page.content_panels + [
|
||||
InlinePanel("featured_events", heading="Fremhevede arrangementer")
|
||||
]
|
||||
|
||||
graphql_fields = [
|
||||
GraphQLCollection(
|
||||
GraphQLForeignKey,
|
||||
"featured_events",
|
||||
"events.EventPage",
|
||||
source="featured_events.event",
|
||||
required=True,
|
||||
item_required=True,
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
class HomePageFeaturedEvents(ClusterableModel, Orderable):
|
||||
parent = ParentalKey("home.HomePage", related_name="featured_events")
|
||||
event = models.ForeignKey(
|
||||
"events.EventPage",
|
||||
on_delete=models.CASCADE,
|
||||
)
|
||||
|
||||
panels = [
|
||||
PageChooserPanel("event", "events.EventPage"),
|
||||
]
|
||||
|
Reference in New Issue
Block a user