Add vintage year to detail
This commit is contained in:
parent
d42bf43d19
commit
019ac97d19
|
|
@ -332,6 +332,13 @@ class Establishment(ProjectBaseMixin, URLImageMixin, TranslatedFieldsMixin):
|
|||
raise ValidationError('Establishment type of subtype does not match')
|
||||
self.establishment_subtypes.add(establishment_subtype)
|
||||
|
||||
|
||||
@property
|
||||
def vintage_year(self):
|
||||
review_qs = self.reviews.by_status(Review.READY)
|
||||
if review_qs.exists():
|
||||
return review_qs.last().vintage
|
||||
|
||||
@property
|
||||
def best_price_menu(self):
|
||||
return 150
|
||||
|
|
|
|||
|
|
@ -199,6 +199,7 @@ class EstablishmentDetailSerializer(EstablishmentListSerializer):
|
|||
best_price_menu = serializers.DecimalField(max_digits=14, decimal_places=2, read_only=True)
|
||||
best_price_carte = serializers.DecimalField(max_digits=14, decimal_places=2, read_only=True)
|
||||
|
||||
vintage_year = serializers.ReadOnlyField()
|
||||
class Meta(EstablishmentListSerializer.Meta):
|
||||
"""Meta class."""
|
||||
|
||||
|
|
@ -222,6 +223,7 @@ class EstablishmentDetailSerializer(EstablishmentListSerializer):
|
|||
'best_price_menu',
|
||||
'best_price_carte',
|
||||
'transportation',
|
||||
'vintage_year',
|
||||
]
|
||||
|
||||
# def get_in_favorites(self, obj):
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user