Added temporary stub for international news logic (hardcoded news id's)
This commit is contained in:
parent
8c5d59e6bf
commit
2b9c9d14ef
|
|
@ -14,15 +14,25 @@ from utils.permissions import IsCountryAdmin, IsContentPageManager
|
|||
class NewsMixinView:
|
||||
"""News mixin."""
|
||||
|
||||
permission_classes = (permissions.AllowAny, )
|
||||
permission_classes = (permissions.AllowAny,)
|
||||
serializer_class = serializers.NewsBaseSerializer
|
||||
|
||||
def get_queryset(self, *args, **kwargs):
|
||||
from django.conf import settings
|
||||
"""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')
|
||||
if self.request.country_code:
|
||||
qs = qs.by_country_code(self.request.country_code)
|
||||
return qs
|
||||
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
|
||||
|
||||
|
||||
class NewsListView(NewsMixinView, generics.ListAPIView):
|
||||
|
|
|
|||
|
|
@ -471,4 +471,4 @@ STATICFILES_DIRS = (
|
|||
|
||||
|
||||
# MEDIA
|
||||
MEDIA_LOCATION = 'media'
|
||||
MEDIA_LOCATION = 'media'
|
||||
|
|
|
|||
|
|
@ -34,3 +34,7 @@ sentry_sdk.init(
|
|||
dsn="https://35d9bb789677410ab84a822831c6314f@sentry.io/1729093",
|
||||
integrations=[DjangoIntegration()]
|
||||
)
|
||||
|
||||
# TMP ( TODO remove it later)
|
||||
# Временный хардкод для демонстрации 4 ноября, потом удалить!
|
||||
HARDCODED_INTERNATIONAL_NEWS_IDS = [8, 9, 10, 11, 15, 17]
|
||||
|
|
|
|||
|
|
@ -88,3 +88,8 @@ ELASTICSEARCH_INDEX_NAMES = {
|
|||
TESTING = sys.argv[1:2] == ['test']
|
||||
if TESTING:
|
||||
ELASTICSEARCH_INDEX_NAMES = {}
|
||||
|
||||
|
||||
# TMP ( TODO remove it later)
|
||||
# Временный хардкод для демонстрации 4 ноября, потом удалить!
|
||||
HARDCODED_INTERNATIONAL_NEWS_IDS = [8, 9, 10, 11, 15, 17]
|
||||
|
|
@ -26,3 +26,8 @@ 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 = [8, 9, 10, 11, 15, 17]
|
||||
Loading…
Reference in New Issue
Block a user