From 5c462e497db7fff45d8eaeedee4ff6703b51374b Mon Sep 17 00:00:00 2001
From: "jindra12.underdark" <jindra12.underdark@gmail.com>
Date: Thu, 20 Jul 2023 02:00:07 +0200
Subject: [PATCH] Start working on uniweb + fix templates

#210
---
 main/models.py                                           | 4 ++--
 main/templates/main/includes/person_article_preview.html | 2 +-
 main/templates/main/includes/work_article_preview.html   | 2 +-
 main/templates/main/main_person_page.html                | 2 +-
 shared/models.py                                         | 5 ++---
 shared/templates/styleguide/2.3.x/article_card.html      | 2 +-
 uniweb/models.py                                         | 9 +--------
 uniweb/templates/uniweb/uniweb_article_page.html         | 2 +-
 8 files changed, 10 insertions(+), 18 deletions(-)

diff --git a/main/models.py b/main/models.py
index 6b839255..0bceaf7f 100644
--- a/main/models.py
+++ b/main/models.py
@@ -525,8 +525,8 @@ class MainArticlesPage(
             self.append_all_shared_articles_query(
                 MainArticlePage.objects.search(
                     request.GET["q"],
-                    custom_article_query=lambda query: query.search(request.GET["q"]),
-                )
+                ),
+                custom_article_query=lambda query: query.search(request.GET["q"]),
             ),
             10,
             request.GET.get("page", 1),
diff --git a/main/templates/main/includes/person_article_preview.html b/main/templates/main/includes/person_article_preview.html
index 4af1c543..89ead973 100644
--- a/main/templates/main/includes/person_article_preview.html
+++ b/main/templates/main/includes/person_article_preview.html
@@ -16,7 +16,7 @@
     <div class="grid-content-with-right-side flex flex-col justify-between items-start mb-9">
       <div class="flex flex-wrap font-bold mb-4 text-xs text-white uppercase">
         <span class="mb-1 bg-green-500 mr-1 px-2 py-2">{{ article_page.date }}</span>
-        {% for tag in article_page.tags.all %}
+        {% for tag in article_page.get_tags %}
           <span class="bg-violet-600 mb-1 mr-1 px-2 py-2">{{ tag }}</span>
         {% endfor %}
       </div>
diff --git a/main/templates/main/includes/work_article_preview.html b/main/templates/main/includes/work_article_preview.html
index 7960f89a..6b75ba17 100644
--- a/main/templates/main/includes/work_article_preview.html
+++ b/main/templates/main/includes/work_article_preview.html
@@ -15,7 +15,7 @@
   </a>
   <div class="flex font-bold mb-4 text-xs text-white uppercase">
     <span class="bg-green-500 mr-1 p-2">{{ article_page.date }}</span>
-    {% for tag in article_page.tags.all %}
+    {% for tag in article_page.get_tags %}
       <span class="bg-violet-600 mr-1 p-2">{{ tag }}</span>
     {% endfor %}
   </div>
diff --git a/main/templates/main/main_person_page.html b/main/templates/main/main_person_page.html
index 22450572..1d6072a3 100644
--- a/main/templates/main/main_person_page.html
+++ b/main/templates/main/main_person_page.html
@@ -150,7 +150,7 @@
             <div class="grid-content-with-right-side flex flex-col justify-between items-start mb-9">
               <div class="flex font-bold mb-4 text-xs text-white uppercase">
                 <span class="bg-green-500 mr-1 px-2 py-2">{{ article_preview.date }}</span>
-                {% for tag in article_preview.tags.all %}
+                {% for tag in article_preview.get_tags %}
                   <span class="bg-violet-600 mr-1 px-2 py-2">{{ tag }}</span>
                 {% endfor %}
               </div>
diff --git a/shared/models.py b/shared/models.py
index 14943b91..c7941d4c 100644
--- a/shared/models.py
+++ b/shared/models.py
@@ -583,9 +583,8 @@ class ArticlesMixin(models.Model):
                 lambda article: article.page_ptr.id,
                 filter(
                     lambda article: article.shared_type == page_type
-                    or (
-                        article.shared_type is None and own_page_type.value == page_type
-                    ),
+                    if article.shared_type is not None
+                    else own_page_type.value == page_type,
                     articles,
                 ),
             )
diff --git a/shared/templates/styleguide/2.3.x/article_card.html b/shared/templates/styleguide/2.3.x/article_card.html
index d5b91089..8b98e342 100644
--- a/shared/templates/styleguide/2.3.x/article_card.html
+++ b/shared/templates/styleguide/2.3.x/article_card.html
@@ -43,7 +43,7 @@
 
     {% if article.has_tags %}
       <div class="inline-block-nogap mt-4">
-        {% for tag in article.tags.all %}
+        {% for tag in article.get_tags %}
           <a href="{% pageurl article.tag_filter_page %}?tag={{ tag }}" class="btn article-card__category-button btn--grey-125 btn--condensed text-sm font-light">
             <div class="btn__body ">{{ tag }}</div>
           </a>
diff --git a/uniweb/models.py b/uniweb/models.py
index 4d38b4fe..0f951727 100644
--- a/uniweb/models.py
+++ b/uniweb/models.py
@@ -558,19 +558,12 @@ class UniwebArticlesIndexPage(
             else articles,
         )
 
-        articles_ids = self.append_all_shared_articles_ids_with_type(
-            own_children,
-            filter=lambda articles: articles.filter(**tag_params)
-            if tag is not None
-            else articles,
-        )
-
         context["articles"] = self.get_page_with_shared_articles(
             articles,
             ARTICLES_PER_PAGE,
             num,
         )
-        context["tags"] = self.search_tags_by_unioned_id_query(articles_ids)
+        context["tags"] = self.search_tags_by_unioned_id_query(articles)
         context["active_tag"] = tag
         return context
 
diff --git a/uniweb/templates/uniweb/uniweb_article_page.html b/uniweb/templates/uniweb/uniweb_article_page.html
index a627ad0a..483fa3aa 100644
--- a/uniweb/templates/uniweb/uniweb_article_page.html
+++ b/uniweb/templates/uniweb/uniweb_article_page.html
@@ -23,7 +23,7 @@
 
       {% if page.has_tags %}
         <div class="my-4">
-          {% for tag in page.tags.all %}
+          {% for tag in page.get_tags %}
             <a href="{% pageurl page.tag_filter_page %}?tag={{ tag }}" class="btn btn--grey-125 btn--condensed">
               <div class="btn__body ">{{ tag }}</div>
             </a>
-- 
GitLab