added assemblage to detail view of product, and fix verbose name in ProductType
This commit is contained in:
parent
8641188c45
commit
1159dfca65
18
apps/product/migrations/0015_auto_20191117_1954.py
Normal file
18
apps/product/migrations/0015_auto_20191117_1954.py
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
# Generated by Django 2.2.7 on 2019-11-17 19:54
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('product', '0014_auto_20191117_1117'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='producttype',
|
||||
name='tag_categories',
|
||||
field=models.ManyToManyField(related_name='product_types', to='tag.TagCategory', verbose_name='Tag categories'),
|
||||
),
|
||||
]
|
||||
|
|
@ -31,7 +31,7 @@ class ProductType(TranslatedFieldsMixin, ProjectBaseMixin):
|
|||
use_subtypes = models.BooleanField(_('Use subtypes'), default=True)
|
||||
tag_categories = models.ManyToManyField('tag.TagCategory',
|
||||
related_name='product_types',
|
||||
verbose_name=_('Tag'))
|
||||
verbose_name=_('Tag categories'))
|
||||
|
||||
class Meta:
|
||||
"""Meta class."""
|
||||
|
|
@ -250,6 +250,10 @@ class Product(GalleryModelMixin, TranslatedFieldsMixin, BaseAttributes):
|
|||
def bottles_produced(self):
|
||||
return self.tags.filter(category__index_name='bottles-produced')
|
||||
|
||||
@property
|
||||
def grape_variety(self):
|
||||
return self.tags.filter(category__index_name='grape-variety')
|
||||
|
||||
@property
|
||||
def related_tags(self):
|
||||
return self.tags.exclude(category__index_name__in=['sugar-content', 'wine-color', 'bottles-produced',
|
||||
|
|
|
|||
|
|
@ -127,6 +127,7 @@ class ProductDetailSerializer(ProductBaseSerializer):
|
|||
wine_sub_region = WineSubRegionBaseSerializer(read_only=True)
|
||||
bottles_produced = TagBaseSerializer(many=True, read_only=True)
|
||||
sugar_contents = TagBaseSerializer(many=True, read_only=True)
|
||||
grape_variety = TagBaseSerializer(many=True, read_only=True)
|
||||
image_url = serializers.URLField(allow_null=True,
|
||||
read_only=True)
|
||||
|
||||
|
|
@ -144,6 +145,7 @@ class ProductDetailSerializer(ProductBaseSerializer):
|
|||
'sugar_contents',
|
||||
'image_url',
|
||||
'new_image',
|
||||
'grape_variety',
|
||||
]
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user