From c064ddbfcb08ac2e6af8b9644402ef37a075e196 Mon Sep 17 00:00:00 2001
From: "jindra12.underdark" <jindra12.underdark@gmail.com>
Date: Sat, 19 Aug 2023 18:04:53 +0200
Subject: [PATCH] Fix shared articles on articles block

#223
---
 uniweb/models.py | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/uniweb/models.py b/uniweb/models.py
index ffdeee74..fdbbbabb 100644
--- a/uniweb/models.py
+++ b/uniweb/models.py
@@ -186,12 +186,11 @@ class ArticlesBlock(blocks.StructBlock):
     def get_context(self, value, parent_context=None):
         context = super().get_context(value, parent_context=parent_context)
         count = value["lines"] * ARTICLES_PER_LINE
-        context["articles"] = (
-            value["page"]
-            .get_children()
-            .live()
-            .specific()
-            .order_by("-uniwebarticlepage__date")[:count]
+        articles_page = value["page"]
+        context["articles"] = articles_page.materialize_shared_articles_query(
+            articles_page.append_all_shared_articles_query(
+                UniwebArticlePage.objects.child_of(articles_page)
+            )[:count]
         )
         return context
 
-- 
GitLab