fix tags indexing
This commit is contained in:
parent
0f0a3f9577
commit
1771b02afd
|
|
@ -5,7 +5,8 @@ from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
from configuration.models import TranslationSettings
|
from configuration.models import TranslationSettings
|
||||||
from location.models import Country
|
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):
|
class TagQuerySet(models.QuerySet):
|
||||||
|
|
@ -50,7 +51,9 @@ class Tag(models.Model):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def label_indexing(self):
|
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()
|
objects = TagQuerySet.as_manager()
|
||||||
|
|
||||||
|
|
@ -155,7 +158,9 @@ class TagCategory(models.Model):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def label_indexing(self):
|
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()
|
objects = TagCategoryQuerySet.as_manager()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user