fix tags indexing

This commit is contained in:
Kuroshini 2019-12-20 21:57:46 +03:00
parent 0f0a3f9577
commit 1771b02afd

View File

@ -5,7 +5,8 @@ from django.utils.translation import gettext_lazy as _
from configuration.models import TranslationSettings
from location.models import Country
from utils.models import TJSONField
from elasticsearch_dsl.utils import AttrDict
from search_indexes.utils import OBJECT_FIELD_PROPERTIES
class TagQuerySet(models.QuerySet):
@ -50,7 +51,9 @@ class Tag(models.Model):
@property
def label_indexing(self):
return self.translation.text
base_dict = self.translation.text if self.translation and isinstance(self.translation.text, dict) else {}
dict_to_index = {locale: base_dict.get(locale) for locale in OBJECT_FIELD_PROPERTIES}
return AttrDict(dict_to_index)
objects = TagQuerySet.as_manager()
@ -155,7 +158,9 @@ class TagCategory(models.Model):
@property
def label_indexing(self):
return self.translation.text
base_dict = self.translation.text if self.translation and isinstance(self.translation.text, dict) else {}
dict_to_index = {locale: base_dict.get(locale) for locale in OBJECT_FIELD_PROPERTIES}
return AttrDict(dict_to_index)
objects = TagCategoryQuerySet.as_manager()