added field - "distillery_types" in establishment list, detail and similar list view

This commit is contained in:
Anatoly 2020-01-13 11:50:54 +03:00
parent d1572cbb56
commit b2f3e1f96b
2 changed files with 7 additions and 0 deletions

View File

@ -854,6 +854,11 @@ class Establishment(GalleryMixin, ProjectBaseMixin, URLImageMixin,
metadata.append(category_tags)
return metadata
@property
def distillery_types(self):
"""Tags from tag category - distillery_type."""
return self.tags.filter(category__index_name='distillery_type')
class EstablishmentNoteQuerySet(models.QuerySet):
"""QuerySet for model EstablishmentNote."""

View File

@ -329,6 +329,7 @@ class EstablishmentBaseSerializer(ProjectModelSerializer):
read_only=True)
tz = serializers.CharField(read_only=True, source='timezone_as_str')
new_image = ImageBaseSerializer(source='crop_main_image', allow_null=True, read_only=True)
distillery_types = TagBaseSerializer(read_only=True, many=True, allow_null=True)
class Meta:
"""Meta class."""
@ -354,6 +355,7 @@ class EstablishmentBaseSerializer(ProjectModelSerializer):
'new_image',
'tz',
'wine_regions',
'distillery_types',
]