From b1c70f58a76629e634e356aa214ef7cc8876bede Mon Sep 17 00:00:00 2001
From: Quido Zientek <quido@codero.cz>
Date: Fri, 26 Aug 2022 13:19:57 +0200
Subject: [PATCH] [FIX] model

---
 main/models.py                                | 4 +++-
 main/templates/main/blocks/twitter_block.html | 2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/main/models.py b/main/models.py
index f8817a710..4127fb078 100644
--- a/main/models.py
+++ b/main/models.py
@@ -160,7 +160,9 @@ class MainHomePage(MenuMixin, ExtendedMetadataHomePageMixin, MetadataPageMixin,
 
     def get_context(self, request, *args, **kwargs):
         context = super().get_context(request, args, kwargs)
-        context["tweet_list"] = Tweet.objects.order_by("-twitter_id")[:4]
+        tweet_list = Tweet.objects.order_by("-twitter_id")
+        context["tweet_list"] = tweet_list[:4]
+        context["show_next_tweet"] = len(tweet_list) > 4
         context["regions"] = REGION_CHOICES
         last_month = timezone.now().today().replace(day=1) - timedelta(days=1)
         first_day_of_last_month = last_month.replace(day=1)
diff --git a/main/templates/main/blocks/twitter_block.html b/main/templates/main/blocks/twitter_block.html
index 991df7b5c..34c4631fc 100644
--- a/main/templates/main/blocks/twitter_block.html
+++ b/main/templates/main/blocks/twitter_block.html
@@ -5,7 +5,7 @@
     <div id="tweetsList">
         {% include 'main/includes/twitter_widget.html' with tweet_list=tweet_list %}
     </div>
-    {% if tweet_list.has_next %}
+    {% if show_next_tweet %}
       <div class="text-center">
           <a
              onclick="showMoreTweets(this)"
-- 
GitLab