From 8ef25e9ed6cb0fe66f064ff893a0023e213ee80f Mon Sep 17 00:00:00 2001 From: Karl Hobley Date: Sun, 23 Feb 2014 15:13:09 +0000 Subject: [PATCH] Removed object_indexed and Indexed.indexed attribute --- wagtail/wagtailcore/models.py | 6 ------ wagtail/wagtailsearch/__init__.py | 1 - wagtail/wagtailsearch/backends/base.py | 8 -------- wagtail/wagtailsearch/backends/elasticsearch.py | 4 ---- wagtail/wagtailsearch/indexed.py | 1 - wagtail/wagtailsearch/models.py | 8 -------- wagtail/wagtailsearch/tests/test_backends.py | 15 --------------- 7 files changed, 43 deletions(-) diff --git a/wagtail/wagtailcore/models.py b/wagtail/wagtailcore/models.py index 65ccaabc36..034df68e1c 100644 --- a/wagtail/wagtailcore/models.py +++ b/wagtail/wagtailcore/models.py @@ -261,12 +261,6 @@ class Page(MP_Node, ClusterableModel, Indexed): cursor.execute(update_statement, [new_url_path, len(old_url_path) + 1, self.path + '%', self.id]) - def object_indexed(self): - # Exclude root node from index - if self.depth == 1: - return False - return True - @property def specific(self): """ diff --git a/wagtail/wagtailsearch/__init__.py b/wagtail/wagtailsearch/__init__.py index db7f93e255..2b074bd9ce 100644 --- a/wagtail/wagtailsearch/__init__.py +++ b/wagtail/wagtailsearch/__init__.py @@ -1,4 +1,3 @@ from indexed import Indexed -from searcher import Searcher from signal_handlers import register_signal_handlers from backends import get_search_backend \ No newline at end of file diff --git a/wagtail/wagtailsearch/backends/base.py b/wagtail/wagtailsearch/backends/base.py index 6b7acb1586..689be7bbea 100644 --- a/wagtail/wagtailsearch/backends/base.py +++ b/wagtail/wagtailsearch/backends/base.py @@ -17,14 +17,6 @@ class BaseSearch(object): if not isinstance(obj, Indexed) or not isinstance(obj, models.Model): return False - # Check if this objects model has opted out of indexing - if not obj.__class__.indexed: - return False - - # Check if this object has an "object_indexed" function - if hasattr(obj, "object_indexed"): - if obj.object_indexed() is False: - return False return True def reset_index(self): diff --git a/wagtail/wagtailsearch/backends/elasticsearch.py b/wagtail/wagtailsearch/backends/elasticsearch.py index 16e156b1a4..87926a3885 100644 --- a/wagtail/wagtailsearch/backends/elasticsearch.py +++ b/wagtail/wagtailsearch/backends/elasticsearch.py @@ -121,10 +121,6 @@ class ElasticSearch(BaseSearch): self.es.create_index(self.es_index, INDEX_SETTINGS) def add_type(self, model): - # Make sure that the model is indexed - if not model.indexed: - return - # Get type name content_type = model.indexed_get_content_type() diff --git a/wagtail/wagtailsearch/indexed.py b/wagtail/wagtailsearch/indexed.py index 135aa7a81a..04d8b0a9eb 100644 --- a/wagtail/wagtailsearch/indexed.py +++ b/wagtail/wagtailsearch/indexed.py @@ -75,4 +75,3 @@ class Indexed(object): return doc indexed_fields = () - indexed = True diff --git a/wagtail/wagtailsearch/models.py b/wagtail/wagtailsearch/models.py index 6d63e40440..809e139ed8 100644 --- a/wagtail/wagtailsearch/models.py +++ b/wagtail/wagtailsearch/models.py @@ -2,7 +2,6 @@ from django.db import models from django.utils import timezone from indexed import Indexed -from searcher import Searcher import datetime import string @@ -100,13 +99,6 @@ class SearchTest(models.Model, Indexed): indexed_fields = ("title", "content", "callable_indexed_field", "live") - title_search = Searcher(["title"]) - - def object_indexed(self): - if self.title == "Don't index me!": - return False - return True - def callable_indexed_field(self): return "Callable" diff --git a/wagtail/wagtailsearch/tests/test_backends.py b/wagtail/wagtailsearch/tests/test_backends.py index 5f1f1a3e76..c8f92b056e 100644 --- a/wagtail/wagtailsearch/tests/test_backends.py +++ b/wagtail/wagtailsearch/tests/test_backends.py @@ -72,17 +72,6 @@ class BackendTests(object): single_result = results[0] multi_result = results[:2] - def test_object_indexed(self): - # Attempt to index something that the models.SearchTest.object_indexed command says should be blocked - test = models.SearchTest() - test.title = "Don't index me!" - test.save() - self.backend.refresh_index() - - # Try to search for this record, It shouldn't be in the index - results = self.backend.search("Don't index me!", models.SearchTest) - self.assertEqual(len(results), 0) - def test_callable_indexed_field(self): # Get results results = self.backend.search("Callable", models.SearchTest) @@ -150,10 +139,6 @@ class TestDBBackend(TestCase, BackendTests): self.backend = get_search_backend('wagtail.wagtailsearch.backends.db.DBSearch') self.load_test_data() - @unittest.expectedFailure - def test_object_indexed(self): - super(TestDBBackend, self).test_object_indexed() - @unittest.expectedFailure def test_callable_indexed_field(self): super(TestDBBackend, self).test_callable_indexed_field()