added two characteristics to wine detail serializer
This commit is contained in:
parent
617552841f
commit
e303e15f32
|
|
@ -267,6 +267,12 @@ class Product(GalleryModelMixin, TranslatedFieldsMixin, BaseAttributes, HasTagsM
|
|||
def bottle_sizes(self):
|
||||
return self.tags.filter(category__index_name='bottle_size')
|
||||
|
||||
@property
|
||||
def alcohol_percentage(self):
|
||||
qs = self.tags.filter(category__index_name='alcohol_percentage')
|
||||
if qs.exists():
|
||||
return qs.first()
|
||||
|
||||
@property
|
||||
def related_tags(self):
|
||||
return super().visible_tags.exclude(category__index_name__in=[
|
||||
|
|
|
|||
|
|
@ -128,6 +128,8 @@ class ProductDetailSerializer(ProductBaseSerializer):
|
|||
bottles_produced = TagBaseSerializer(many=True, read_only=True)
|
||||
sugar_contents = TagBaseSerializer(many=True, read_only=True)
|
||||
grape_variety = TagBaseSerializer(many=True, read_only=True)
|
||||
bottle_sizes = TagBaseSerializer(many=True, read_only=True)
|
||||
alcohol_percentage = TagBaseSerializer(read_only=True)
|
||||
image_url = serializers.URLField(allow_null=True,
|
||||
read_only=True)
|
||||
new_image = ImageBaseSerializer(source='crop_main_image', allow_null=True, read_only=True)
|
||||
|
|
@ -146,6 +148,8 @@ class ProductDetailSerializer(ProductBaseSerializer):
|
|||
'new_image',
|
||||
'grape_variety',
|
||||
'average_price',
|
||||
'bottle_sizes',
|
||||
'alcohol_percentage',
|
||||
]
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user