Merge branch 'feature/international_news_stub' into 'develop'

Added temporary stub for international news logic (hardcoded news id's)

See merge request gm/gm-backend!64
This commit is contained in:
d.kuzmenko 2019-10-24 12:21:59 +00:00
commit d09ca51d48
5 changed files with 30 additions and 6 deletions

View File

@ -15,13 +15,23 @@ class NewsMixinView:
"""News mixin.""" """News mixin."""
permission_classes = (permissions.AllowAny,) permission_classes = (permissions.AllowAny,)
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().with_base_related() \ qs = models.News.objects.published().with_base_related() \
.order_by('-is_highlighted', '-created') .order_by('-is_highlighted', '-created')
if self.request.country_code: country_code = self.request.country_code
qs = qs.by_country_code(self.request.country_code) if country_code and country_code != 'www' and country_code != 'main':
return qs.by_country_code(self.request.country_code)
else:
if settings.HARDCODED_INTERNATIONAL_NEWS_IDS:
# Temporary stub for international news logic
# (по договорённости с заказчиком на демонстрации 4 ноября здесь будет 6 фиксированных новостей)
# TODO replace this stub with actual logic
return models.News.objects.filter(id__in=settings.HARDCODED_INTERNATIONAL_NEWS_IDS)
else:
return qs return qs

View File

@ -34,3 +34,7 @@ sentry_sdk.init(
dsn="https://35d9bb789677410ab84a822831c6314f@sentry.io/1729093", dsn="https://35d9bb789677410ab84a822831c6314f@sentry.io/1729093",
integrations=[DjangoIntegration()] integrations=[DjangoIntegration()]
) )
# TMP ( TODO remove it later)
# Временный хардкод для демонстрации 4 ноября, потом удалить!
HARDCODED_INTERNATIONAL_NEWS_IDS = [8, 9, 10, 11, 15, 17]

View File

@ -88,3 +88,8 @@ ELASTICSEARCH_INDEX_NAMES = {
TESTING = sys.argv[1:2] == ['test'] TESTING = sys.argv[1:2] == ['test']
if TESTING: if TESTING:
ELASTICSEARCH_INDEX_NAMES = {} ELASTICSEARCH_INDEX_NAMES = {}
# TMP ( TODO remove it later)
# Временный хардкод для демонстрации 4 ноября, потом удалить!
HARDCODED_INTERNATIONAL_NEWS_IDS = [8, 9, 10, 11, 15, 17]

View File

@ -26,3 +26,8 @@ ELASTICSEARCH_INDEX_NAMES = {
# 'search_indexes.documents.news': 'stage_news', #temporarily disabled # 'search_indexes.documents.news': 'stage_news', #temporarily disabled
'search_indexes.documents.establishment': 'stage_establishment', 'search_indexes.documents.establishment': 'stage_establishment',
} }
# TMP ( TODO remove it later)
# Временный хардкод для демонстрации 4 ноября, потом удалить!
HARDCODED_INTERNATIONAL_NEWS_IDS = [8, 9, 10, 11, 15, 17]