reviews or bo list
This commit is contained in:
parent
e4547b9554
commit
9084fbeab6
|
|
@ -137,6 +137,14 @@ class EstablishmentQuerySet(models.QuerySet):
|
||||||
"""Return qs with related reviews."""
|
"""Return qs with related reviews."""
|
||||||
return self.prefetch_related('reviews')
|
return self.prefetch_related('reviews')
|
||||||
|
|
||||||
|
def with_reviews_sorted(self):
|
||||||
|
return self.prefetch_related(
|
||||||
|
Prefetch(
|
||||||
|
'reviews',
|
||||||
|
queryset=Review.objects.published().order_by('-published_at'),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
def with_currency_related(self):
|
def with_currency_related(self):
|
||||||
"""Return qs with related """
|
"""Return qs with related """
|
||||||
return self.prefetch_related('currency')
|
return self.prefetch_related('currency')
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ from collection.models import Guide
|
||||||
from establishment import models, serializers as model_serializers
|
from establishment import models, serializers as model_serializers
|
||||||
from establishment.models import ContactEmail, ContactPhone, EstablishmentEmployee
|
from establishment.models import ContactEmail, ContactPhone, EstablishmentEmployee
|
||||||
from establishment.serializers.common import ContactPhonesSerializer
|
from establishment.serializers.common import ContactPhonesSerializer
|
||||||
|
from review.serializers.common import ReviewBaseSerializer
|
||||||
from gallery.models import Image
|
from gallery.models import Image
|
||||||
from location.serializers import AddressDetailSerializer, TranslatedField, AddressBaseSerializer, \
|
from location.serializers import AddressDetailSerializer, TranslatedField, AddressBaseSerializer, \
|
||||||
AddressEstablishmentSerializer
|
AddressEstablishmentSerializer
|
||||||
|
|
@ -92,7 +93,7 @@ class EstablishmentListCreateSerializer(model_serializers.EstablishmentBaseSeria
|
||||||
)
|
)
|
||||||
subtypes = model_serializers.EstablishmentSubTypeBaseSerializer(source='establishment_subtypes',
|
subtypes = model_serializers.EstablishmentSubTypeBaseSerializer(source='establishment_subtypes',
|
||||||
read_only=True, many=True)
|
read_only=True, many=True)
|
||||||
|
reviews = ReviewBaseSerializer(allow_null=True, read_only=True, many=True)
|
||||||
restaurant_category = TagBaseSerializer(read_only=True, many=True, allow_null=True)
|
restaurant_category = TagBaseSerializer(read_only=True, many=True, allow_null=True)
|
||||||
restaurant_cuisine = TagBaseSerializer(read_only=True, many=True, allow_null=True)
|
restaurant_cuisine = TagBaseSerializer(read_only=True, many=True, allow_null=True)
|
||||||
artisan_category = TagBaseSerializer(read_only=True, many=True, allow_null=True)
|
artisan_category = TagBaseSerializer(read_only=True, many=True, allow_null=True)
|
||||||
|
|
@ -137,6 +138,7 @@ class EstablishmentListCreateSerializer(model_serializers.EstablishmentBaseSeria
|
||||||
'artisan_category',
|
'artisan_category',
|
||||||
'distillery_type',
|
'distillery_type',
|
||||||
'food_producer',
|
'food_producer',
|
||||||
|
'reviews',
|
||||||
]
|
]
|
||||||
|
|
||||||
def to_representation(self, instance):
|
def to_representation(self, instance):
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,8 @@ class EstablishmentListCreateView(EstablishmentMixinViews, generics.ListCreateAP
|
||||||
.with_certain_tag_category_related('cuisine', 'restaurant_cuisine') \
|
.with_certain_tag_category_related('cuisine', 'restaurant_cuisine') \
|
||||||
.with_certain_tag_category_related('shop_category', 'artisan_category') \
|
.with_certain_tag_category_related('shop_category', 'artisan_category') \
|
||||||
.with_certain_tag_category_related('distillery_type', 'distillery_type') \
|
.with_certain_tag_category_related('distillery_type', 'distillery_type') \
|
||||||
.with_certain_tag_category_related('producer_type', 'food_producer')
|
.with_certain_tag_category_related('producer_type', 'food_producer') \
|
||||||
|
.with_reviews_sorted()
|
||||||
|
|
||||||
|
|
||||||
class EmployeeEstablishmentPositionsView(generics.ListAPIView):
|
class EmployeeEstablishmentPositionsView(generics.ListAPIView):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user