Remove all crunches from projects
This commit is contained in:
parent
c5e96a7ad8
commit
f52847a71a
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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."""
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -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):
|
||||
|
|
|
|||
|
|
@ -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']
|
||||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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]
|
||||
Loading…
Reference in New Issue
Block a user