Skip to content
This repository has been archived by the owner on Oct 29, 2019. It is now read-only.

Commit

Permalink
Fixes for several issues with preparing search_data
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcustos committed Jul 9, 2017
1 parent 9a54645 commit 885e4d7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions aldryn_newsblog/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,11 @@ def get_search_data(self, language=None, request=None):
language = get_current_language()
if request is None:
request = get_request(language=language)
description = self.safe_translation_getter('lead_in', '')
description = self.safe_translation_getter('lead_in', '', language)
text_bits = [strip_tags(description)]
for category in self.categories.all():
text_bits.append(
force_unicode(category.safe_translation_getter('name')))
force_unicode(category.safe_translation_getter('name', language_code=language)))
for tag in self.tags.all():
text_bits.append(force_unicode(tag.name))
if self.content:
Expand All @@ -233,7 +233,7 @@ def get_search_data(self, language=None, request=None):
def save(self, *args, **kwargs):
# Update the search index
if self.update_search_on_save:
self.search_data = self.get_search_data()
self.search_data = self.get_search_data(self.language_code)

# Ensure there is an owner.
if self.app_config.create_authors and self.author is None:
Expand Down Expand Up @@ -560,5 +560,5 @@ def update_search_data(sender, instance, **kwargs):
if placeholder._attached_model_cache == Article:
article = placeholder._attached_model_cache.objects.language(
instance.language).get(content=placeholder.pk)
article.search_data = article.get_search_data(instance.language)
# NOTE: search_data will be updated in save()
article.save()

0 comments on commit 885e4d7

Please sign in to comment.