diff --git a/apps/news/views.py b/apps/news/views.py index e0034afa..51d49be3 100644 --- a/apps/news/views.py +++ b/apps/news/views.py @@ -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): diff --git a/apps/search_indexes/documents/news.py b/apps/search_indexes/documents/news.py index 0d1cc765..699a1cca 100644 --- a/apps/search_indexes/documents/news.py +++ b/apps/search_indexes/documents/news.py @@ -42,8 +42,6 @@ class NewsDocument(Document): 'slug', 'state', 'is_highlighted', - # 'image_url', - # 'preview_image_url', 'template', ) related_models = [models.NewsType] diff --git a/project/settings/base.py b/project/settings/base.py index 02df804e..f9524f94 100644 --- a/project/settings/base.py +++ b/project/settings/base.py @@ -471,4 +471,4 @@ STATICFILES_DIRS = ( # MEDIA -MEDIA_LOCATION = 'media' \ No newline at end of file +MEDIA_LOCATION = 'media' diff --git a/project/settings/development.py b/project/settings/development.py index 59691818..9f950abf 100644 --- a/project/settings/development.py +++ b/project/settings/development.py @@ -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] diff --git a/project/settings/local.py b/project/settings/local.py index e87b99f6..1b511692 100644 --- a/project/settings/local.py +++ b/project/settings/local.py @@ -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] \ No newline at end of file diff --git a/project/settings/stage.py b/project/settings/stage.py index 49a7ae0f..0afe7e4e 100644 --- a/project/settings/stage.py +++ b/project/settings/stage.py @@ -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] \ No newline at end of file