fix collection establishment in_fav

This commit is contained in:
alex 2019-11-18 13:12:24 +03:00
parent d0fec2591f
commit dc0b4ce107
2 changed files with 23 additions and 4 deletions

View File

@ -18,8 +18,8 @@ class CollectionViewMixin(generics.GenericAPIView):
def get_queryset(self):
"""Override get_queryset method."""
return models.Collection.objects.published() \
.by_country_code(code=self.request.country_code) \
.order_by('-on_top', '-modified')
.by_country_code(code=self.request.country_code) \
.order_by('-on_top', '-modified')
class GuideViewMixin(generics.GenericAPIView):
@ -40,7 +40,7 @@ class CollectionHomePageView(CollectionListView):
def get_queryset(self):
"""Override get_queryset."""
return super(CollectionHomePageView, self).get_queryset() \
.filter_all_related_gt(3)
.filter_all_related_gt(3)
class CollectionDetailView(CollectionViewMixin, generics.RetrieveAPIView):
@ -66,7 +66,7 @@ class CollectionEstablishmentListView(CollectionListView):
# May raise a permission denied
self.check_object_permissions(self.request, collection)
return collection.establishments.all()
return collection.establishments.all().annotate_in_favorites(self.request.user)
# Guide

View File

@ -0,0 +1,19 @@
# Generated by Django 2.2.4 on 2019-11-18 10:11
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('location', '0026_country_is_active'),
]
operations = [
migrations.AlterField(
model_name='winesubregion',
name='wine_region',
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='wine_sub_region', to='location.WineRegion', verbose_name='wine sub region'),
),
]