add some basic search functionality
This commit is contained in:
@ -9,6 +9,7 @@ from grapple.models import (
|
||||
from wagtail.admin.panels import FieldPanel
|
||||
from wagtail.fields import RichTextField
|
||||
from wagtail.models import Page
|
||||
from wagtail.search import index
|
||||
|
||||
from dnscms.fields import CommonStreamField
|
||||
|
||||
@ -32,6 +33,8 @@ class AssociationIndex(Page):
|
||||
GraphQLStreamfield("body"),
|
||||
]
|
||||
|
||||
search_fields = Page.search_fields
|
||||
|
||||
|
||||
class AssociationPage(Page):
|
||||
subpage_types = []
|
||||
@ -75,3 +78,8 @@ class AssociationPage(Page):
|
||||
GraphQLString("website_url"),
|
||||
GraphQLString("association_type"),
|
||||
]
|
||||
|
||||
search_fields = Page.search_fields + [
|
||||
index.SearchField("excerpt"),
|
||||
index.SearchField("body"),
|
||||
]
|
||||
|
@ -9,6 +9,7 @@ from wagtail.admin.panels import (
|
||||
)
|
||||
from wagtail.fields import RichTextField, StreamField
|
||||
from wagtail.models import Page
|
||||
from wagtail.search import index
|
||||
from wagtail.snippets.models import register_snippet
|
||||
|
||||
from contacts.blocks import ContactSectionBlock
|
||||
@ -37,6 +38,8 @@ class ContactIndex(Page):
|
||||
|
||||
graphql_fields = [GraphQLRichText("lead"), GraphQLStreamfield("body")]
|
||||
|
||||
search_fields = Page.search_fields + [index.SearchField("body")]
|
||||
|
||||
|
||||
@register_snippet
|
||||
@register_query_field("contactEntity", "contactEntities")
|
||||
|
@ -25,6 +25,7 @@ from wagtail.admin.panels import (
|
||||
TitleFieldPanel,
|
||||
)
|
||||
from wagtail.models import Orderable, Page, PageManager, PageQuerySet
|
||||
from wagtail.search import index
|
||||
from wagtail.snippets.models import register_snippet
|
||||
|
||||
from associations.widgets import AssociationChooserWidget
|
||||
@ -65,6 +66,8 @@ class EventIndex(Page):
|
||||
),
|
||||
]
|
||||
|
||||
search_fields = []
|
||||
|
||||
|
||||
@register_snippet
|
||||
@register_query_field("eventCategory", "eventCategories")
|
||||
@ -374,6 +377,8 @@ class EventPage(Page):
|
||||
),
|
||||
]
|
||||
|
||||
search_fields = Page.search_fields + [index.SearchField("body")]
|
||||
|
||||
def clean(self):
|
||||
super().clean()
|
||||
|
||||
|
@ -2,6 +2,7 @@ from grapple.models import GraphQLRichText, GraphQLStreamfield
|
||||
from wagtail.admin.panels import FieldPanel
|
||||
from wagtail.fields import RichTextField, StreamField
|
||||
from wagtail.models import Page
|
||||
from wagtail.search import index
|
||||
|
||||
from dnscms.blocks import PageSectionBlock
|
||||
from dnscms.fields import BASE_BLOCKS
|
||||
@ -23,3 +24,5 @@ class GenericPage(Page):
|
||||
GraphQLRichText("lead"),
|
||||
GraphQLStreamfield("body"),
|
||||
]
|
||||
|
||||
search_fields = Page.search_fields + [index.SearchField("lead"), index.SearchField("body")]
|
||||
|
@ -30,6 +30,8 @@ class HomePage(Page):
|
||||
),
|
||||
]
|
||||
|
||||
search_fields = []
|
||||
|
||||
|
||||
class HomePageFeaturedEvents(ClusterableModel, Orderable):
|
||||
parent = ParentalKey("home.HomePage", related_name="featured_events")
|
||||
|
@ -43,6 +43,8 @@ class CustomImage(AbstractImage):
|
||||
GraphQLString("attribution"),
|
||||
]
|
||||
|
||||
search_fields = []
|
||||
|
||||
|
||||
class Rendition(AbstractRendition):
|
||||
image = models.ForeignKey(CustomImage, on_delete=models.CASCADE, related_name="renditions")
|
||||
|
@ -4,6 +4,7 @@ from grapple.models import GraphQLImage, GraphQLRichText, GraphQLStreamfield, Gr
|
||||
from wagtail.admin.panels import FieldPanel
|
||||
from wagtail.fields import RichTextField
|
||||
from wagtail.models import Page
|
||||
from wagtail.search import index
|
||||
|
||||
from dnscms.fields import CommonStreamField
|
||||
|
||||
@ -23,6 +24,8 @@ class NewsIndex(Page):
|
||||
GraphQLRichText("lead"),
|
||||
]
|
||||
|
||||
search_fields = []
|
||||
|
||||
|
||||
class NewsPage(Page):
|
||||
subpage_types = []
|
||||
@ -65,3 +68,9 @@ class NewsPage(Page):
|
||||
GraphQLStreamfield("body"),
|
||||
GraphQLImage("featured_image"),
|
||||
]
|
||||
|
||||
search_fields = Page.search_fields + [
|
||||
index.SearchField("excerpt", boost=1),
|
||||
index.SearchField("lead", boost=1),
|
||||
index.SearchField("body"),
|
||||
]
|
||||
|
@ -10,6 +10,7 @@ from grapple.models import (
|
||||
from wagtail.admin.panels import FieldPanel, FieldRowPanel, MultiFieldPanel
|
||||
from wagtail.fields import RichTextField
|
||||
from wagtail.models import Page
|
||||
from wagtail.search import index
|
||||
|
||||
from dnscms.fields import CommonStreamField
|
||||
|
||||
@ -137,3 +138,8 @@ class VenuePage(Page):
|
||||
GraphQLString("capacity_standing"),
|
||||
GraphQLString("capacity_sitting"),
|
||||
]
|
||||
|
||||
search_fields = Page.search_fields + [
|
||||
index.SearchField("lead"),
|
||||
index.SearchField("body"),
|
||||
]
|
||||
|
Reference in New Issue
Block a user