33 lines
971 B
Python
33 lines
971 B
Python
from django.db import models
|
|
from project.common.blocks import build_stream_field
|
|
from wagtail.wagtailcore.models import Page
|
|
from wagtail.wagtailadmin.edit_handlers import FieldPanel, StreamFieldPanel
|
|
from wagtail.wagtailimages.edit_handlers import ImageChooserPanel
|
|
from wagtail.wagtailsearch import index
|
|
|
|
from project.common.models import Entity
|
|
|
|
|
|
class BlogPage(Entity):
|
|
main_image = models.ForeignKey(
|
|
'wagtailimages.Image',
|
|
null=True,
|
|
blank=True,
|
|
on_delete=models.SET_NULL,
|
|
related_name='+'
|
|
)
|
|
date = models.DateField("Post date")
|
|
intro = models.CharField(max_length=250)
|
|
body = build_stream_field()
|
|
|
|
search_fields = Page.search_fields + [
|
|
index.SearchField('intro'),
|
|
index.SearchField('body'),
|
|
]
|
|
|
|
content_panels = Page.content_panels + [
|
|
FieldPanel('date'),
|
|
ImageChooserPanel('main_image'),
|
|
FieldPanel('intro'),
|
|
StreamFieldPanel('body'),
|
|
]
|