remove hardcoded news
This commit is contained in:
parent
346f126dbb
commit
83bab7f383
|
|
@ -18,29 +18,12 @@ class NewsMixinView:
|
||||||
serializer_class = serializers.NewsBaseSerializer
|
serializer_class = serializers.NewsBaseSerializer
|
||||||
|
|
||||||
def get_queryset(self, *args, **kwargs):
|
def get_queryset(self, *args, **kwargs):
|
||||||
from django.conf import settings
|
|
||||||
"""Override get_queryset method."""
|
"""Override get_queryset method."""
|
||||||
|
|
||||||
qs = models.News.objects.published() \
|
qs = models.News.objects.published() \
|
||||||
.with_base_related() \
|
.with_base_related() \
|
||||||
.order_by('-is_highlighted', '-created')
|
.order_by('-is_highlighted', '-created')
|
||||||
country_code = self.request.country_code
|
country_code = self.request.country_code
|
||||||
if 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)
|
qs = qs.by_country_code(country_code)
|
||||||
return qs
|
return qs
|
||||||
|
|
||||||
|
|
@ -51,10 +34,6 @@ class NewsListView(NewsMixinView, generics.ListAPIView):
|
||||||
serializer_class = serializers.NewsListSerializer
|
serializer_class = serializers.NewsListSerializer
|
||||||
filter_class = filters.NewsListFilterSet
|
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):
|
class NewsDetailView(NewsMixinView, generics.RetrieveAPIView):
|
||||||
"""News detail view."""
|
"""News detail view."""
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user