iamkonstantin/home/models.py

59 lines
1.6 KiB
Python
Raw Normal View History

2024-02-29 18:51:43 +01:00
from django.db import models
from wagtail.models import Page
2024-04-05 19:03:18 +02:00
from wagtail.fields import RichTextField, StreamField
2024-02-29 21:44:43 +01:00
from wagtail.admin.panels import FieldPanel, MultiFieldPanel
2024-03-23 16:50:24 +01:00
from wagtailseo.models import SeoMixin
2024-04-05 19:03:18 +02:00
from .blocks import HomeContentBlock
2024-02-29 18:51:43 +01:00
2024-03-23 16:50:24 +01:00
class HomePage(SeoMixin, Page):
2024-02-29 21:44:43 +01:00
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",
)
2024-04-05 19:03:18 +02:00
body = StreamField(
HomeContentBlock(),
blank=True,
use_json_field=True,
help_text="Write anything",
)
2024-02-29 18:51:43 +01:00
content_panels = Page.content_panels + [
2024-02-29 21:44:43 +01:00
MultiFieldPanel(
[
FieldPanel("image"),
FieldPanel("hero_text"),
FieldPanel("hero_cta"),
FieldPanel("hero_cta_link"),
],
heading="Hero section",
),
2024-02-29 18:51:43 +01:00
FieldPanel('body'),
]
2024-03-23 16:50:24 +01:00
promote_panels = SeoMixin.seo_panels