32 lines
869 B
Python
32 lines
869 B
Python
from project.common.blocks import build_stream_field
|
|
from wagtail.admin.edit_handlers import StreamFieldPanel, FieldPanel
|
|
from wagtail.search import index
|
|
from project.common.models import Entity
|
|
from django.db import models
|
|
|
|
from modelcluster.fields import ParentalKey
|
|
from modelcluster.contrib.taggit import ClusterTaggableManager
|
|
from taggit.models import TaggedItemBase
|
|
|
|
|
|
class BlogPageTag(TaggedItemBase):
|
|
content_object = ParentalKey(
|
|
'BlogPage',
|
|
related_name='tagged_items',
|
|
on_delete=models.CASCADE
|
|
)
|
|
|
|
|
|
class BlogPage(Entity):
|
|
body = build_stream_field()
|
|
|
|
tags = ClusterTaggableManager(through=BlogPageTag, blank=True)
|
|
|
|
search_fields = Entity.search_fields + [
|
|
index.SearchField('body'),
|
|
]
|
|
|
|
content_panels = Entity.content_panels + [
|
|
StreamFieldPanel('body'),
|
|
FieldPanel('tags')
|
|
]
|