kopia lustrzana https://github.com/wagtail/wagtail
Search: Updated search handlers and tests to use get_search_backend
rodzic
e0ee842594
commit
54d46db2c2
|
@ -1,16 +1,16 @@
|
|||
from django.db.models.signals import post_save, post_delete
|
||||
from django.db import models
|
||||
|
||||
from search import Search
|
||||
from indexed import Indexed
|
||||
from wagtail.wagtailsearch.indexed import Indexed
|
||||
from wagtail.wagtailsearch.backends import get_search_backend
|
||||
|
||||
|
||||
def post_save_signal_handler(instance, **kwargs):
|
||||
Search().add(instance)
|
||||
get_search_backend().add(instance)
|
||||
|
||||
|
||||
def post_delete_signal_handler(instance, **kwargs):
|
||||
Search().delete(instance)
|
||||
get_search_backend().delete(instance)
|
||||
|
||||
|
||||
def register_signal_handlers():
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
from django.test import TestCase
|
||||
|
||||
import models
|
||||
from search import Search
|
||||
from wagtail.wagtailsearch.backends import get_search_backend()
|
||||
|
||||
|
||||
class TestSearch(TestCase):
|
||||
def test_search(self):
|
||||
# Create search interface and reset the index
|
||||
s = Search()
|
||||
# Create search backend and reset the index
|
||||
s = get_search_backend()
|
||||
s.reset_index()
|
||||
|
||||
# Create a couple of objects and add them to the index
|
||||
|
|
Ładowanie…
Reference in New Issue