search: only index sites with a "site contents" cell (#15460)

This commit is contained in:
Frédéric Péters 2017-03-17 08:53:22 +01:00
parent 634aa90931
commit 118f69bb22
5 changed files with 30 additions and 1 deletions

View File

View File

@ -0,0 +1,28 @@
# combo - content management system
# Copyright (C) 2017 Entr'ouvert
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from haystack.management.commands.update_index import Command as UpdateIndexCommand
from combo.apps.search.models import SearchCell
class Command(UpdateIndexCommand):
def handle(self, **options):
if SearchCell.objects.filter(_search_service='_text').count() == 0:
# do not index site if there's no matching search cell
return
return super(Command, self).handle(**options)

View File

@ -57,7 +57,6 @@ INSTALLED_APPS = (
'django.contrib.staticfiles',
'rest_framework',
'ckeditor',
'haystack',
'gadjo',
'cmsplugin_blurp',
'combo.data',
@ -74,6 +73,7 @@ INSTALLED_APPS = (
'combo.apps.notifications',
'combo.apps.search',
'combo.apps.usersearch',
'haystack',
'xstatic.pkg.chartnew_js',
)

View File

@ -10,6 +10,7 @@ from django.core.urlresolvers import reverse
from haystack.exceptions import SkipDocument
from combo.apps.search.management.commands.update_index import Command
from combo.apps.search.models import SearchCell
from combo.data.models import Page, JsonCell, TextCell, MenuCell
from combo.data.search_indexes import PageIndex