feat(pages.py): add blog pages
This commit is contained in:
@@ -1,15 +1,17 @@
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
from django.contrib.auth.models import Group, User
|
||||
from django.conf import settings
|
||||
from django.contrib.auth.models import Group, User
|
||||
from django.db import models
|
||||
from django.forms import CheckboxSelectMultiple
|
||||
from django.utils import timezone
|
||||
from modelcluster.contrib.taggit import ClusterTaggableManager
|
||||
from modelcluster.fields import ParentalKey
|
||||
from taggit.models import TaggedItemBase
|
||||
from wagtail import blocks
|
||||
from wagtail.admin.panels import FieldPanel
|
||||
from wagtail.fields import RichTextField
|
||||
from wagtail.fields import RichTextField, StreamField
|
||||
from wagtail.images.blocks import ImageBlock
|
||||
from wagtail.models import Page
|
||||
from wagtail.models.copying import ParentalManyToManyField
|
||||
from wagtail_color_panel.edit_handlers import NativeColorPanel
|
||||
@@ -28,6 +30,10 @@ class HomePage(Page):
|
||||
content_panels = Page.content_panels + ["body"]
|
||||
|
||||
|
||||
class BlogIndexPage(Page):
|
||||
subpage_types = ["home.BlogPage"]
|
||||
|
||||
|
||||
class CourseIndexPage(Page):
|
||||
subpage_types = ["home.CoursePage"]
|
||||
|
||||
@@ -50,6 +56,31 @@ class CourseIndexPage(Page):
|
||||
return context
|
||||
|
||||
|
||||
class BlogPage(Page):
|
||||
author = models.CharField(max_length=255)
|
||||
image = models.ForeignKey(
|
||||
"wagtailimages.Image",
|
||||
null=True,
|
||||
blank=True,
|
||||
on_delete=models.SET_NULL,
|
||||
related_name="+",
|
||||
)
|
||||
body = StreamField(
|
||||
[
|
||||
("heading", blocks.CharBlock(classname="title")),
|
||||
("paragraph", blocks.RichTextBlock()),
|
||||
("image", ImageBlock()),
|
||||
]
|
||||
)
|
||||
|
||||
content_panels = Page.content_panels + [
|
||||
FieldPanel("author"),
|
||||
FieldPanel("image"),
|
||||
FieldPanel("body"),
|
||||
]
|
||||
parent_page_types = ["home.BlogIndexPage"]
|
||||
|
||||
|
||||
class CoursePage(Page):
|
||||
course_image = models.ForeignKey(
|
||||
"wagtailimages.Image",
|
||||
|
||||
Reference in New Issue
Block a user