Return hardcode for chosen tags
This commit is contained in:
parent
71dd52c194
commit
798e58202c
|
|
@ -70,6 +70,9 @@ class CarouselListView(generics.ListAPIView):
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
country_code = self.request.country_code
|
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()
|
qs = models.Carousel.objects.is_parsed().active()
|
||||||
if country_code:
|
if country_code:
|
||||||
qs = qs.by_country_code(country_code)
|
qs = qs.by_country_code(country_code)
|
||||||
|
|
|
||||||
|
|
@ -52,3 +52,17 @@ class TagsFilterSet(TagsBaseFilterSet):
|
||||||
|
|
||||||
model = models.Tag
|
model = models.Tag
|
||||||
fields = ('type',)
|
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,6 +23,23 @@ class ChosenTagsView(generics.ListAPIView, viewsets.GenericViewSet):
|
||||||
.filter(id__in=result_tags_ids) \
|
.filter(id__in=result_tags_ids) \
|
||||||
.order_by_priority()
|
.order_by_priority()
|
||||||
|
|
||||||
|
def list(self, request, *args, **kwargs):
|
||||||
|
# TMP TODO remove it later
|
||||||
|
# Временный хардкод для демонстрации > 15 ноября, потом удалить!
|
||||||
|
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
|
# User`s views & viewsets
|
||||||
class TagCategoryViewSet(mixins.ListModelMixin, viewsets.GenericViewSet):
|
class TagCategoryViewSet(mixins.ListModelMixin, viewsets.GenericViewSet):
|
||||||
|
|
|
||||||
|
|
@ -487,3 +487,9 @@ PHONENUMBER_DB_FORMAT = 'NATIONAL'
|
||||||
PHONENUMBER_DEFAULT_REGION = "FR"
|
PHONENUMBER_DEFAULT_REGION = "FR"
|
||||||
|
|
||||||
FALLBACK_LOCALE = 'en-GB'
|
FALLBACK_LOCALE = 'en-GB'
|
||||||
|
|
||||||
|
# TMP TODO remove it later
|
||||||
|
# Временный хардкод для демонстрации > 15 ноября, потом удалить!
|
||||||
|
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']
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user