From 5c545156bf1893118e8153c029e321b6755157e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Valenta?= <git@imaniti.org> Date: Thu, 18 Jan 2024 20:17:23 +0100 Subject: [PATCH] auto-resize text when title is too long --- shared/models/base.py | 8 ++++---- shared/models/main.py | 12 ++++++------ .../includes/organisms/header/article_header.html | 4 +++- .../organisms/header/elections/article_header.html | 6 +++++- .../organisms/header/elections/simple_header.html | 2 +- .../includes/organisms/header/simple_header.html | 2 +- 6 files changed, 20 insertions(+), 14 deletions(-) diff --git a/shared/models/base.py b/shared/models/base.py index d1ffa6e3..93a977ff 100644 --- a/shared/models/base.py +++ b/shared/models/base.py @@ -693,21 +693,21 @@ class ArticlesMixin: ) if self.get_shared_tags().count() == 0: - return prepared_query.order_by("-union_date") + return prepared_query.order_by("-union_timestamp") return ( prepared_query.union(main_by_values) .union(uniweb_by_values) .union(district_by_values) .union(elections_by_values) - .order_by("-union_date") + .order_by("-union_timestamp") ) else: return ( main_by_values.union(uniweb_by_values) .union(district_by_values) .union(elections_by_values) - .order_by("-union_date") + .order_by("-union_timestamp") ) def materialize_shared_articles_query(self, results): @@ -824,7 +824,7 @@ class ArticlesMixin: lambda unioned: TmpArticle( page_ptr=TmpPrimaryKey(id=unioned["union_page_ptr_id"]), ), - articles.values("union_page_ptr_id", "union_date"), + articles.values("union_page_ptr_id", "union_timestamp"), ) ) diff --git a/shared/models/main.py b/shared/models/main.py index c18e2e8e..94a82f42 100644 --- a/shared/models/main.py +++ b/shared/models/main.py @@ -266,7 +266,7 @@ class MainHomePageMixin( context["article_data_list"] = self.materialize_shared_articles_query( self.append_all_shared_articles_query( self.article_page_model.objects.live().all() - ).order_by("-union_date")[:3] + ).order_by("-union_timestamp")[:3] ) return context @@ -447,7 +447,7 @@ class MainArticlesPageMixin( return self.materialize_shared_articles_query( self.append_all_shared_articles_query( self.root_page.article_page_model.objects.filter(filter).live().all() - ).order_by("-union_date") + ).order_by("-union_timestamp") ) def get_article_data_list( @@ -460,12 +460,12 @@ class MainArticlesPageMixin( target_date_list = self.append_all_shared_articles_query( self.root_page.article_page_model.objects.filter(search_filter).live() - ).order_by("-union_date") + ).order_by("-union_timestamp") if not target_date_list: return [] - target_date = target_date_list[0]["union_date"] - relativedelta( + target_date = target_date_list[0]["union_timestamp"] - relativedelta( months=months_back ) first_day_of_target_month = target_date.replace(day=1) @@ -546,7 +546,7 @@ class MainArticlesPageMixin( self.root_page.article_page_model.objects.filter(search_filter) .live() .all() - ).order_by("union_date")[ + ).order_by("union_timestamp")[ :2 ] # LIMIT 2 )[0] @@ -595,7 +595,7 @@ class MainArticlesPageMixin( ) .live() .all() - ).order_by("union_date")[ + ).order_by("union_timestamp")[ :2 ] # LIMIT 2 )[0] diff --git a/shared/templates/styleguide2/includes/organisms/header/article_header.html b/shared/templates/styleguide2/includes/organisms/header/article_header.html index 5b3bb655..c04b4706 100644 --- a/shared/templates/styleguide2/includes/organisms/header/article_header.html +++ b/shared/templates/styleguide2/includes/organisms/header/article_header.html @@ -4,4 +4,6 @@ {% include 'styleguide2/includes/atoms/header/navigation.html' with classes='mb-6' first_text=first_nav_text first_link=first_nav_link second_text=second_nav_text second_link=None %} {% endblock %} -{% block heading_classes %}head-8xl{% endblock %} +{% block heading_classes %} + {% if title|length <= 100 %}head-8xl{% else %}head-7xl{% endif %} +{% endblock %} diff --git a/shared/templates/styleguide2/includes/organisms/header/elections/article_header.html b/shared/templates/styleguide2/includes/organisms/header/elections/article_header.html index cae5cc5b..0e8fe325 100644 --- a/shared/templates/styleguide2/includes/organisms/header/elections/article_header.html +++ b/shared/templates/styleguide2/includes/organisms/header/elections/article_header.html @@ -4,6 +4,10 @@ {% include 'styleguide2/includes/atoms/header/elections/navigation.html' with classes='mb-6' first_text=first_nav_text first_link=first_nav_link second_text=second_nav_text second_link=None %} {% endblock %} -{% block heading_classes %}!text-black head-8xl{% endblock %} +{% block heading_classes %} + !text-black + + {% if title|length <= 100 %}head-8xl{% else %}head-7xl{% endif %} +{% endblock %} {% block description_classes %}!text-black{% endblock %} diff --git a/shared/templates/styleguide2/includes/organisms/header/elections/simple_header.html b/shared/templates/styleguide2/includes/organisms/header/elections/simple_header.html index 759bc153..ae3a9fc0 100644 --- a/shared/templates/styleguide2/includes/organisms/header/elections/simple_header.html +++ b/shared/templates/styleguide2/includes/organisms/header/elections/simple_header.html @@ -14,7 +14,7 @@ {% if is_short %}head-short{% endif %} {% if description %} - head-8xl + {% if title|length <= 100 %}head-8xl{% else %}head-7xl{% endif %} {% else %} head-14xl {% endif %} diff --git a/shared/templates/styleguide2/includes/organisms/header/simple_header.html b/shared/templates/styleguide2/includes/organisms/header/simple_header.html index 8ae4f4dc..eb9e969e 100644 --- a/shared/templates/styleguide2/includes/organisms/header/simple_header.html +++ b/shared/templates/styleguide2/includes/organisms/header/simple_header.html @@ -24,7 +24,7 @@ {% if is_short %}head-short{% endif %} {% if description %} - head-8xl + {% if title|length <= 100 %}head-8xl{% else %}head-7xl{% endif %} {% else %} head-14xl {% endif %} -- GitLab