GM-67: Внедрить передачу флага нахождения заведения в избранном пользователя
This commit is contained in:
parent
7577ad330c
commit
2f5240adfa
|
|
@ -214,6 +214,16 @@ class EstablishmentDetailSerializer(EstablishmentListSerializer):
|
|||
return ReviewSerializer(obj.reviews.by_status(status=review_models.Review.READY)
|
||||
.order_by('-published_at').first()).data
|
||||
|
||||
def get_in_favorites(self, obj):
|
||||
"""Get in_favorites status flag"""
|
||||
user = self.context.get('request').user
|
||||
if user.is_authenticated:
|
||||
return obj.id in user.favorites.by_content_type(app_label='establishment',
|
||||
model='establishment')\
|
||||
.values_list('object_id', flat=True)
|
||||
else:
|
||||
return False
|
||||
|
||||
|
||||
class EstablishmentCommentCreateSerializer(comment_serializers.CommentSerializer):
|
||||
"""Create comment serializer"""
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user