changed representation of product name in ProductBaseSerializer
This commit is contained in:
parent
e08bd8508a
commit
a6d064daba
|
|
@ -258,7 +258,15 @@ class Product(TranslatedFieldsMixin, BaseAttributes):
|
||||||
def related_tags(self):
|
def related_tags(self):
|
||||||
return self.tags.exclude(
|
return self.tags.exclude(
|
||||||
category__index_name__in=['sugar-content', 'wine-color', 'bottles-produced',
|
category__index_name__in=['sugar-content', 'wine-color', 'bottles-produced',
|
||||||
'serial-number'])
|
'serial-number', 'grape-variety'])
|
||||||
|
|
||||||
|
@property
|
||||||
|
def display_name(self):
|
||||||
|
name = f'{self.name} ' \
|
||||||
|
f'({self.vintage if self.vintage else "BSA"})'
|
||||||
|
if self.establishment.name:
|
||||||
|
name = f'{self.establishment.name} - ' + name
|
||||||
|
return name
|
||||||
|
|
||||||
|
|
||||||
class OnlineProductManager(ProductManager):
|
class OnlineProductManager(ProductManager):
|
||||||
|
|
|
||||||
|
|
@ -85,6 +85,7 @@ class ProductStandardBaseSerializer(serializers.ModelSerializer):
|
||||||
|
|
||||||
class ProductBaseSerializer(serializers.ModelSerializer):
|
class ProductBaseSerializer(serializers.ModelSerializer):
|
||||||
"""Product base serializer."""
|
"""Product base serializer."""
|
||||||
|
name = serializers.CharField(source='display_name', read_only=True)
|
||||||
product_type = serializers.CharField(source='product_type_translated_name', read_only=True)
|
product_type = serializers.CharField(source='product_type_translated_name', read_only=True)
|
||||||
subtypes = ProductSubTypeBaseSerializer(many=True, read_only=True)
|
subtypes = ProductSubTypeBaseSerializer(many=True, read_only=True)
|
||||||
establishment_detail = EstablishmentShortSerializer(source='establishment', read_only=True)
|
establishment_detail = EstablishmentShortSerializer(source='establishment', read_only=True)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user