58 lines
1.6 KiB
Python
58 lines
1.6 KiB
Python
from django.db import models
|
|
|
|
from wagtail.models import Page
|
|
from wagtail.fields import RichTextField, StreamField
|
|
from wagtail.admin.panels import FieldPanel, MultiFieldPanel
|
|
from wagtailseo.models import SeoMixin
|
|
from .blocks import HomeContentBlock
|
|
|
|
|
|
class HomePage(SeoMixin, Page):
|
|
image = models.ForeignKey(
|
|
"wagtailimages.Image",
|
|
null=True,
|
|
blank=True,
|
|
on_delete=models.SET_NULL,
|
|
related_name="+",
|
|
help_text="Homepage image",
|
|
)
|
|
hero_text = models.CharField(
|
|
blank=True,
|
|
max_length=255, help_text="Write an introduction for the site"
|
|
)
|
|
hero_cta = models.CharField(
|
|
blank=True,
|
|
verbose_name="Hero CTA",
|
|
max_length=255,
|
|
help_text="Text to display on Call to Action",
|
|
)
|
|
hero_cta_link = models.ForeignKey(
|
|
"wagtailcore.Page",
|
|
null=True,
|
|
blank=True,
|
|
on_delete=models.SET_NULL,
|
|
related_name="+",
|
|
verbose_name="Hero CTA link",
|
|
help_text="Choose a page to link to for the Call to Action",
|
|
)
|
|
body = StreamField(
|
|
HomeContentBlock(),
|
|
blank=True,
|
|
use_json_field=True,
|
|
help_text="Write anything",
|
|
)
|
|
|
|
content_panels = Page.content_panels + [
|
|
MultiFieldPanel(
|
|
[
|
|
FieldPanel("image"),
|
|
FieldPanel("hero_text"),
|
|
FieldPanel("hero_cta"),
|
|
FieldPanel("hero_cta_link"),
|
|
],
|
|
heading="Hero section",
|
|
),
|
|
FieldPanel('body'),
|
|
]
|
|
|
|
promote_panels = SeoMixin.seo_panels
|