From f52847a71a891a53b673f9dd7ef4509e1a0760d7 Mon Sep 17 00:00:00 2001 From: Kuroshini Date: Wed, 16 Oct 2019 14:11:07 +0300 Subject: [PATCH] Remove all crunches from projects --- apps/main/views/common.py | 3 --- apps/news/views.py | 20 -------------------- apps/tag/filters.py | 15 --------------- apps/tag/views.py | 17 ----------------- project/settings/base.py | 6 ------ project/settings/development.py | 4 ---- project/settings/production.py | 4 ---- project/settings/stage.py | 5 ----- 8 files changed, 74 deletions(-) diff --git a/apps/main/views/common.py b/apps/main/views/common.py index 15f89510..0c2ef6d4 100644 --- a/apps/main/views/common.py +++ b/apps/main/views/common.py @@ -70,9 +70,6 @@ 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 e91003e8..b6016446 100644 --- a/apps/news/views.py +++ b/apps/news/views.py @@ -18,7 +18,6 @@ class NewsMixinView: serializer_class = serializers.NewsBaseSerializer def get_queryset(self, *args, **kwargs): - from django.conf import settings """Override get_queryset method.""" qs = models.News.objects.published() \ @@ -26,21 +25,6 @@ class NewsMixinView: .order_by('-is_highlighted', '-created') country_code = self.request.country_code if country_code: - - # temp code - # Temporary stub for international news logic - # (по договорённости с заказчиком на демонстрации 4 ноября - # здесь будет 6 фиксированных новостей) - # TODO replace this stub with actual logic - 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: - qs = models.News.objects.filter( - old_id__in=settings.HARDCODED_INTERNATIONAL_NEWS_IDS) - return qs - # temp code - qs = qs.by_country_code(country_code) return qs @@ -51,10 +35,6 @@ 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/apps/tag/filters.py b/apps/tag/filters.py index 2dc3a775..e8263e0d 100644 --- a/apps/tag/filters.py +++ b/apps/tag/filters.py @@ -54,18 +54,3 @@ class TagsFilterSet(TagsBaseFilterSet): model = models.Tag fields = ('type',) - - - # TMP TODO remove it later - # Временный хардкод для демонстрации 4 ноября, потом удалить! - def filter_by_type(self, queryset, name, value): - """ Overrides base filter. Temporary decision""" - if not (settings.NEWS_CHOSEN_TAGS and settings.ESTABLISHMENT_CHOSEN_TAGS): - return super().filter_by_type(queryset, name, value) - queryset = models.Tag.objects - if self.NEWS in value: - queryset = queryset.for_news().filter(value__in=settings.NEWS_CHOSEN_TAGS).distinct('value') - if self.ESTABLISHMENT in value: - queryset = queryset.for_establishments().filter(value__in=settings.ESTABLISHMENT_CHOSEN_TAGS).distinct( - 'value') - return queryset \ No newline at end of file diff --git a/apps/tag/views.py b/apps/tag/views.py index a4beaaa0..c55834e0 100644 --- a/apps/tag/views.py +++ b/apps/tag/views.py @@ -23,23 +23,6 @@ class ChosenTagsView(generics.ListAPIView, viewsets.GenericViewSet): .filter(id__in=result_tags_ids) \ .order_by_priority() - def list(self, request, *args, **kwargs): - # TMP TODO remove it later - # Временный хардкод для демонстрации 4 ноября, потом удалить! - queryset = self.filter_queryset(self.get_queryset()) - - page = self.paginate_queryset(queryset) - if page is not None: - serializer = self.get_serializer(page, many=True) - return self.get_paginated_response(serializer.data) - - serializer = self.get_serializer(queryset, many=True) - result_list = serializer.data - if request.query_params.get('type') and (settings.ESTABLISHMENT_CHOSEN_TAGS or settings.NEWS_CHOSEN_TAGS): - ordered_list = settings.ESTABLISHMENT_CHOSEN_TAGS if request.query_params.get('type') == 'establishment' else settings.NEWS_CHOSEN_TAGS - result_list = sorted(result_list, key=lambda x: ordered_list.index(x['index_name'])) - return Response(result_list) - # User`s views & viewsets class TagCategoryViewSet(mixins.ListModelMixin, viewsets.GenericViewSet): diff --git a/project/settings/base.py b/project/settings/base.py index 839ee9e0..80baf04a 100644 --- a/project/settings/base.py +++ b/project/settings/base.py @@ -490,9 +490,3 @@ PHONENUMBER_DB_FORMAT = 'NATIONAL' PHONENUMBER_DEFAULT_REGION = "FR" 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 diff --git a/project/settings/development.py b/project/settings/development.py index c6f80f9e..16297f40 100644 --- a/project/settings/development.py +++ b/project/settings/development.py @@ -38,10 +38,6 @@ sentry_sdk.init( integrations=[DjangoIntegration()] ) -# TMP ( TODO remove it later) -# Временный хардкод для демонстрации 4 ноября, потом удалить! -HARDCODED_INTERNATIONAL_NEWS_IDS = [1460, 1471, 1482, 1484, 1611, 1612] - # Database # https://docs.djangoproject.com/en/2.2/ref/settings/#databases diff --git a/project/settings/production.py b/project/settings/production.py index 49e972d6..a531a2ae 100644 --- a/project/settings/production.py +++ b/project/settings/production.py @@ -40,10 +40,6 @@ sentry_sdk.init( integrations=[DjangoIntegration()] ) -# TMP ( TODO remove it later) -# Временный хардкод для демонстрации 4 ноября, потом удалить! -HARDCODED_INTERNATIONAL_NEWS_IDS = [1460, 1471, 1482, 1484, 1611, 1612] - # Database # https://docs.djangoproject.com/en/2.2/ref/settings/#databases diff --git a/project/settings/stage.py b/project/settings/stage.py index b70563c9..49a7ae0f 100644 --- a/project/settings/stage.py +++ b/project/settings/stage.py @@ -26,8 +26,3 @@ ELASTICSEARCH_INDEX_NAMES = { # 'search_indexes.documents.news': 'stage_news', #temporarily disabled 'search_indexes.documents.establishment': 'stage_establishment', } - - -# TMP ( TODO remove it later) -# Временный хардкод для демонстрации 4 ноября, потом удалить! -HARDCODED_INTERNATIONAL_NEWS_IDS = [1460, 1471, 1482, 1484, 1611, 1612] \ No newline at end of file