Exclude listing pages from search

This commit is contained in:
Jake Howard 2023-12-25 22:10:17 +00:00
parent 1276d54972
commit b13fe49664
Signed by: jake
GPG key ID: 57AFB45680EDD477

View file

@ -9,7 +9,7 @@ from wagtail.contrib.routable_page.models import RoutablePageMixin, route
from wagtail.models import Page from wagtail.models import Page
from wagtail.search.utils import parse_query_string from wagtail.search.utils import parse_query_string
from website.common.models import BaseContentPage from website.common.models import BaseContentPage, BaseListingPage
from website.common.utils import get_page_models from website.common.utils import get_page_models
from .serializers import MIN_SEARCH_LENGTH, SearchParamsSerializer from .serializers import MIN_SEARCH_LENGTH, SearchParamsSerializer
@ -22,7 +22,10 @@ class SearchPage(RoutablePageMixin, BaseContentPage):
PAGE_SIZE = 12 PAGE_SIZE = 12
# Exclude singleton pages from search results # Exclude singleton pages from search results
EXCLUDED_PAGE_TYPES = {page for page in get_page_models() if page.max_count == 1} EXCLUDED_PAGE_TYPES = {
*(page for page in get_page_models() if page.max_count == 1),
BaseListingPage,
}
@cached_property @cached_property
def show_reading_time(self) -> bool: def show_reading_time(self) -> bool: