Skip to content

Commit

Permalink
Merge pull request #8 from benzkji/develop
Browse files Browse the repository at this point in the history
make cms index optional, fix ugly placeholderindexing bug
  • Loading branch information
benzkji authored Jan 31, 2024
2 parents a217523 + 475874d commit 0e64cda
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 6 additions & 1 deletion postgres_searchindex/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
},
)


LANGUAGE_2_PGCONFIG = getattr(
settings,
"POSTGRES_SEARCHINDEX_LANGUAGE_2_PGCONFIG",
Expand All @@ -18,3 +17,9 @@
"fr": "french",
},
)

USE_CMS_INDEX = getattr(
settings,
"POSTGRES_SEARCHINDEX_USE_CMS_INDEX",
True,
)
7 changes: 4 additions & 3 deletions postgres_searchindex/contrib/djangocms/index_sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from postgres_searchindex.base import MultiLanguageIndexSource
from postgres_searchindex.contrib.djangocms.base import PlaceholderIndexSourceMixin
from postgres_searchindex.source_pool import source_pool
from postgres_searchindex import conf


class TitleIndexSource(PlaceholderIndexSourceMixin, MultiLanguageIndexSource):
Expand All @@ -27,8 +28,7 @@ def get_placeholder_content(self, obj, language, request):
)
text = ""
for base_plugin in plugins:
text = " " + self.get_plugin_search_text(base_plugin, request)

text += " " + self.get_plugin_search_text(base_plugin, request)
return text

def get_queryset(self):
Expand All @@ -49,4 +49,5 @@ def get_queryset(self):
return queryset.distinct()


source_pool.register(TitleIndexSource)
if conf.USE_CMS_INDEX:
source_pool.register(TitleIndexSource)

0 comments on commit 0e64cda

Please sign in to comment.