Fix ES product relations & swagger

This commit is contained in:
Kuroshini 2019-10-16 14:11:07 +03:00
parent 2ca4ab6bb5
commit 36f4ab1dd9
2 changed files with 5 additions and 6 deletions

View File

@ -80,9 +80,10 @@ class ProductQuerySet(models.QuerySet):
def with_es_related(self):
"""Returns qs with related for ES indexing."""
return self.with_base_related().prefetch_related('tags', 'classifications', 'classifications__tags',
'classifications__type', 'classifications_standard',
'standards').select_related('wine_region', 'wine_sub_region')
return self.with_base_related()\
.prefetch_related('tags', 'standards','classifications', 'classifications__standard',
'classifications__classification_type','classifications__tags')\
.select_related('wine_region', 'wine_sub_region')
def common(self):
return self.filter(category=self.model.COMMON)

View File

@ -26,9 +26,7 @@ class ProductSubtypeDocumentSerializer(serializers.Serializer):
id = serializers.IntegerField()
name_translated = serializers.SerializerMethodField()
@staticmethod
def get_name_translted(obj):
return get_translated_value(obj.name)
get_name_translated = lambda obj: get_translated_value(obj.name)
class WineRegionCountryDocumentSerialzer(serializers.Serializer):