diff --git a/apps/main/views/common.py b/apps/main/views/common.py index d509f80e..15f89510 100644 --- a/apps/main/views/common.py +++ b/apps/main/views/common.py @@ -1,5 +1,6 @@ """Main app views.""" from django.http import Http404 +from django.conf import settings from rest_framework import generics, permissions from rest_framework.response import Response @@ -69,6 +70,9 @@ class CarouselListView(generics.ListAPIView): def get_queryset(self): country_code = self.request.country_code + if hasattr(settings, 'CAROUSEL_ITEMS') and country_code in ['www', 'main']: + qs = models.Carousel.objects.filter(id__in=settings.CAROUSEL_ITEMS) + return qs qs = models.Carousel.objects.is_parsed().active() if country_code: qs = qs.by_country_code(country_code) diff --git a/apps/news/views.py b/apps/news/views.py index 990665dd..04fa29a1 100644 --- a/apps/news/views.py +++ b/apps/news/views.py @@ -32,7 +32,7 @@ class NewsMixinView: # (по договорённости с заказчиком на демонстрации 4 ноября # здесь будет 6 фиксированных новостей) # TODO replace this stub with actual logic - if hasattr(settings, 'HARDCODED_INTERNATIONAL_NEWS_IDS'): + if hasattr(settings, 'HARDCODED_INTERNATIONAL_NEWS_IDS') and kwargs.get('hardcoded_only', False): if country_code and country_code != 'www' and country_code != 'main': qs = qs.by_country_code(country_code) else: @@ -51,6 +51,10 @@ class NewsListView(NewsMixinView, generics.ListAPIView): serializer_class = serializers.NewsListSerializer filter_class = filters.NewsListFilterSet + def get_queryset(self, *args, **kwargs): + kwargs.update({'hardcoded_only': True}) + super().get_queryset(*args, **kwargs) + class NewsDetailView(NewsMixinView, generics.RetrieveAPIView): """News detail view.""" diff --git a/project/settings/base.py b/project/settings/base.py index 686f246e..839ee9e0 100644 --- a/project/settings/base.py +++ b/project/settings/base.py @@ -493,5 +493,6 @@ FALLBACK_LOCALE = 'en-GB' # TMP TODO remove it later # Временный хардкод для демонстрации 4 ноября, потом удалить! +CAROUSEL_ITEMS = [230, 231, 232] ESTABLISHMENT_CHOSEN_TAGS = ['gastronomic', 'en_vogue', 'terrace', 'streetfood', 'business', 'bar_cocktail', 'brunch', 'pop'] NEWS_CHOSEN_TAGS = ['eat', 'drink', 'cook', 'style', 'international', 'event', 'partnership'] \ No newline at end of file