Ensure additional content fields get indexed

This commit is contained in:
Jake Howard 2022-07-28 23:06:11 +01:00
parent 863b0f67c5
commit cf0a365277
Signed by: jake
GPG key ID: 57AFB45680EDD477
4 changed files with 15 additions and 0 deletions

View file

@ -24,6 +24,7 @@ class BlogListPage(BaseContentMixin, RoutablePageMixin, BasePage): # type: igno
"blog.BlogCollectionPage",
]
content_panels = BasePage.content_panels + BaseContentMixin.content_panels
search_fields = BasePage.search_fields + BaseContentMixin.search_fields
@cached_property
def reading_time(self) -> int:
@ -71,6 +72,7 @@ class BlogListPage(BaseContentMixin, RoutablePageMixin, BasePage): # type: igno
class BlogPostPage(BaseContentMixin, BasePage): # type: ignore[misc]
subpage_types: list[Any] = []
parent_page_types = [BlogListPage, "blog.BlogCollectionPage"]
search_fields = BasePage.search_fields + BaseContentMixin.search_fields
tags = ParentalManyToManyField("blog.BlogPostTagPage", blank=True)
date = models.DateField(default=timezone.now)
@ -88,6 +90,7 @@ class BlogPostTagListPage(BaseContentMixin, BasePage): # type: ignore[misc]
subpage_types = ["blog.BlogPostTagPage"]
content_panels = BasePage.content_panels + BaseContentMixin.content_panels
search_fields = BasePage.search_fields + BaseContentMixin.search_fields
@cached_property
def table_of_contents(self) -> list[TocEntry]:
@ -107,6 +110,7 @@ class BlogPostTagPage(BaseContentMixin, RoutablePageMixin, BasePage): # type: i
parent_page_types = [BlogPostTagListPage]
content_panels = BasePage.content_panels + BaseContentMixin.content_panels
search_fields = BasePage.search_fields + BaseContentMixin.search_fields
@cached_property
def table_of_contents(self) -> list[TocEntry]:
@ -138,6 +142,7 @@ class BlogCollectionListPage(BaseContentMixin, BasePage): # type: ignore[misc]
max_count = 1
content_panels = BasePage.content_panels + BaseContentMixin.content_panels
search_fields = BasePage.search_fields + BaseContentMixin.search_fields
@cached_property
def table_of_contents(self) -> list[TocEntry]:
@ -160,6 +165,7 @@ class BlogCollectionPage(BaseContentMixin, BasePage): # type: ignore[misc]
subpage_types = [BlogPostPage]
content_panels = BasePage.content_panels + BaseContentMixin.content_panels
search_fields = BasePage.search_fields + BaseContentMixin.search_fields
@cached_property
def table_of_contents(self) -> list[TocEntry]:

View file

@ -54,6 +54,11 @@ class BaseContentMixin(models.Model):
FieldPanel("body"),
]
search_fields = [
index.SearchField("body"),
index.SearchField("subtitle"),
]
class Meta:
abstract = True
@ -100,10 +105,12 @@ class BaseContentMixin(models.Model):
class ContentPage(BasePage, BaseContentMixin): # type: ignore[misc]
subpage_types: list[Any] = []
content_panels = BasePage.content_panels + BaseContentMixin.content_panels
search_fields = BasePage.search_fields + BaseContentMixin.search_fields
class ListingPage(BasePage, BaseContentMixin): # type: ignore[misc]
content_panels = BasePage.content_panels + BaseContentMixin.content_panels
search_fields = BasePage.search_fields + BaseContentMixin.search_fields
def get_context(self, request: HttpRequest) -> dict:
context = super().get_context(request)

View file

@ -40,6 +40,7 @@ class ContactPage(BaseContentMixin, BasePage): # type: ignore[misc]
max_count = 1
subpage_types: list = []
content_panels = BasePage.content_panels + BaseContentMixin.content_panels
search_fields = BasePage.search_fields + BaseContentMixin.search_fields
@cached_property
def reading_time(self) -> int:

View file

@ -15,6 +15,7 @@ class SearchPage(BaseContentMixin, BasePage): # type: ignore[misc]
subpage_types: list = []
parent_page_types = ["home.HomePage"]
content_panels = BasePage.content_panels + BaseContentMixin.content_panels
search_fields = BasePage.search_fields + BaseContentMixin.search_fields
@cached_property
def reading_time(self) -> int: