From 8d713dd5ebb7b5ae584472745864b2210f74c459 Mon Sep 17 00:00:00 2001 From: krmax44 Date: Tue, 1 Oct 2024 14:38:45 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=84=20hide=20gap=20in=20authors=20list?= =?UTF-8?q?=20when=20no=20one=20has=20a=20profile=20picture?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../templates/fds_blog/includes/_authors.html | 31 ++++++++++--------- .../includes/blog_item_featured_top.html | 2 +- .../fds_blog/templatetags/blog_tags.py | 9 ++++-- 3 files changed, 25 insertions(+), 17 deletions(-) diff --git a/fragdenstaat_de/fds_blog/templates/fds_blog/includes/_authors.html b/fragdenstaat_de/fds_blog/templates/fds_blog/includes/_authors.html index c68a448e2..42818f912 100644 --- a/fragdenstaat_de/fds_blog/templates/fds_blog/includes/_authors.html +++ b/fragdenstaat_de/fds_blog/templates/fds_blog/includes/_authors.html @@ -1,21 +1,24 @@ {% load thumbnail %} {% load i18n %} +{% load blog_tags %} {% if authors %}
- {# authors are also linked with text below, so spare screenreaders/keyboard nav #} - + {% if authors|has_author_images %} + {# authors are also linked with text below, so spare screenreaders/keyboard nav #} + + {% endif %}

{% trans "by" %} diff --git a/fragdenstaat_de/fds_blog/templates/fds_blog/includes/blog_item_featured_top.html b/fragdenstaat_de/fds_blog/templates/fds_blog/includes/blog_item_featured_top.html index 20cff7ba1..d00a99e5d 100644 --- a/fragdenstaat_de/fds_blog/templates/fds_blog/includes/blog_item_featured_top.html +++ b/fragdenstaat_de/fds_blog/templates/fds_blog/includes/blog_item_featured_top.html @@ -12,7 +12,7 @@

{% include "fds_blog/includes/_item_meta.html" with hide_date=True %}
- {% include "fds_blog/includes/_authors.html" with authors=article.authors.all hide_date=True %} + {% include "fds_blog/includes/_authors.html" with authors=article.get_authors hide_date=True %}
diff --git a/fragdenstaat_de/fds_blog/templatetags/blog_tags.py b/fragdenstaat_de/fds_blog/templatetags/blog_tags.py index 9519625ba..b484e0fda 100644 --- a/fragdenstaat_de/fds_blog/templatetags/blog_tags.py +++ b/fragdenstaat_de/fds_blog/templatetags/blog_tags.py @@ -1,10 +1,10 @@ import re -from typing import Tuple +from typing import List, Tuple from django import template from ..managers import articles_published -from ..models import Article +from ..models import Article, Author register = template.Library() @@ -46,3 +46,8 @@ def get_blog_preview(context, amount=6): articles = Article.published.all()[:amount] return {"articles": articles, "request": context.get("request")} + + +@register.filter +def has_author_images(authors: List[Author]) -> bool: + return any(author.user and author.user.profile_photo for author in authors)