From dd44db105caeb35ae2d87d01247f0fb30a8a8fc3 Mon Sep 17 00:00:00 2001
From: Ondrej Rehounek <ondra.rehounek@seznam.cz>
Date: Sun, 18 Sep 2022 08:35:21 +0200
Subject: [PATCH] district & shared: more ifs for rendering candidate bio

---
 .../templates/elections2021/_candidate_list_item.html | 10 +++++++++-
 .../blocks/compact_candidate_snippet_block.html       | 11 ++++++-----
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/elections2021/templates/elections2021/_candidate_list_item.html b/elections2021/templates/elections2021/_candidate_list_item.html
index f0244069..7647a45a 100644
--- a/elections2021/templates/elections2021/_candidate_list_item.html
+++ b/elections2021/templates/elections2021/_candidate_list_item.html
@@ -5,7 +5,15 @@
     {% image candidate.photo fill-100x100 %}
   </div>
   <div class="candidate-table-row__name head-heavy-2xs font-bold">{{ candidate.title }}</div>
-  <div class="candidate-table-row__bio font-condensed">{{ candidate.age }} let, {{ candidate.occupation }}, {{ candidate.city }}</div>
+  <div class="candidate-table-row__bio font-condensed">
+    {% if candidate.age %}
+      {{ candidate.age }}&nbsp;let{% if candidate.job or candidate.city %},{% endif %}
+    {% endif %}
+    {% if candidate.job %}
+     {{ candidate.job }}{% if candidate.city %},{% endif %}
+    {% endif %}
+    {% if candidate.city %}{{ candidate.city }}{% endif %}
+  </div>
   <div class="candidate-table-row__affiliation">
     <div class="w-6 mr-2">
       {% if candidate.is_pirate %}
diff --git a/shared/templates/shared/blocks/compact_candidate_snippet_block.html b/shared/templates/shared/blocks/compact_candidate_snippet_block.html
index acd2bb85..dbcedfc6 100644
--- a/shared/templates/shared/blocks/compact_candidate_snippet_block.html
+++ b/shared/templates/shared/blocks/compact_candidate_snippet_block.html
@@ -19,13 +19,14 @@
     {{ block.title }}
   </div>
   <div class="candidate-table-row__bio font-condensed">
-    {% if person_page.age %}
-      {{ person_page.age }}&nbsp;let{% if person_page.job or person_page.city %},{% endif %}
+    <div class="candidate-table-row__bio font-condensed">
+    {% if block.age %}
+      {{ block.age }}&nbsp;let{% if block.job or block.city %},{% endif %}
     {% endif %}
-    {% if person_page.job %}
-     {{ person_page.job }}{% if person_page.city %},{% endif %}
+    {% if block.job %}
+     {{ block.job }}{% if block.city %},{% endif %}
     {% endif %}
-    {% if person_page.city %}{{ person_page.city }}{% endif %}
+    {% if block.city %}{{ block.city }}{% endif %}
   </div>
   <div class="candidate-table-row__affiliation">
     <div class="flex items-center">
-- 
GitLab