From 37560ba068a1228306efc76d468975e88886ed1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0t=C4=9Bp=C3=A1n=20Farka?= <stepanfarka11@gmail.com> Date: Tue, 30 Aug 2022 16:43:11 +0200 Subject: [PATCH] [FIX] article first --- main/models.py | 5 +++- main/templates/main/blocks/news_block.html | 30 ++++++++++++---------- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/main/models.py b/main/models.py index df2f8202a..683738d2b 100644 --- a/main/models.py +++ b/main/models.py @@ -165,7 +165,10 @@ class MainHomePage(MenuMixin, ExtendedMetadataHomePageMixin, MetadataPageMixin, context["article_data_list"] = MainArticlePage.objects.filter( region__isnull=False ).order_by("-date")[:3] - context["article_carousel_list"] = MainArticlePage.objects.order_by("-date")[:8] + + articles_for_article_section = MainArticlePage.objects.order_by("-date") + context["article_main"] = articles_for_article_section[:1] + context["article_carousel_list"] = articles_for_article_section[1:8] return context diff --git a/main/templates/main/blocks/news_block.html b/main/templates/main/blocks/news_block.html index ac0d3bc63..0dc78b489 100644 --- a/main/templates/main/blocks/news_block.html +++ b/main/templates/main/blocks/news_block.html @@ -5,21 +5,23 @@ <h2 class="head-7xl xl:text-center mb-6 xl:mb-28"> {{ self.title }} </h2> - <div class="flex flex-wrap mb-5 lg:mb-10"> - {% image article_data_list.0.image original as article_img %} - <img src="{{ article_img.url }}" draggable="false" alt="" class="lg:max-w-lg lg:mr-11 h-fit"> - <div class="flex flex-col max-w-xl items-start"> - <span class="text-green-500 head-3xl mt-10 mb-4 lg:mb-8">{{ article_data_list.0.date }}</span> - <h5 class="head-4xl mb-5 lg:mb-10">{{ article_data_list.0.title }}</h5> - <p class="leading-6 mb-4 lg:mb-8">{{ article_data_list.0.perex }}</p> - {% include 'main/includes/button_animated.html' with btn_link=article_data_list.0.url btn_text="Číst dále" %} + {% if article_main %} + <div class="flex flex-wrap mb-5 lg:mb-10"> + {% image article_main.image original as article_img %} + <img src="{{ article_img.url }}" draggable="false" alt="" class="lg:max-w-lg lg:mr-11 h-fit"> + <div class="flex flex-col max-w-xl items-start"> + <span class="text-green-500 head-3xl mt-10 mb-4 lg:mb-8">{{ article_main.date }}</span> + <h5 class="head-4xl mb-5 lg:mb-10">{{ article_main.title }}</h5> + <p class="leading-6 mb-4 lg:mb-8">{{ article_main.perex }}</p> + {% include 'main/includes/button_animated.html' with btn_link=article_main.url btn_text="Číst dále" %} + </div> </div> - </div> - <div class="__js-root"> - <ui-article-carousel> - {% include 'main/includes/article_carousel_item.html' with article_carousel_list=article_carousel_list %} - </ui-article-carousel> - </div> + <div class="__js-root"> + <ui-article-carousel> + {% include 'main/includes/article_carousel_item.html' with article_carousel_list=article_carousel_list %} + </ui-article-carousel> + </div> + {% endif %} </div> </div> -- GitLab