From e22a2edd27695b08085d09f7904429482f5ee092 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Valenta?= <tomas@imaniti.org>
Date: Tue, 2 Jul 2024 11:53:41 +0200
Subject: [PATCH] add full name to candidate list

---
 shared/models/main.py                             | 15 ++++++++++++++-
 .../candidates/candidate_secondary_box.html       |  2 +-
 .../candidates/candidate_primary_list.html        |  4 ++--
 3 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/shared/models/main.py b/shared/models/main.py
index e130483c..2e0289ca 100644
--- a/shared/models/main.py
+++ b/shared/models/main.py
@@ -1922,6 +1922,8 @@ class MainPersonPageMixin(
         FieldPanel("related_people"),
     ]
 
+    ### OTHERS
+
     def get_context(self, request) -> dict:
         context = super().get_context(request)
 
@@ -1933,7 +1935,18 @@ class MainPersonPageMixin(
 
         return context
 
-    ### OTHERS
+    def get_full_name(self) -> str:
+        full_name = ""
+
+        if self.before_name:
+            full_name += f"{self.before_name} "
+
+        full_name += self.title
+
+        if self.after_name:
+            full_name += f", {self.after_name}"
+
+        return full_name
 
     class Meta:
         verbose_name = "Detail osoby"
diff --git a/shared/templates/styleguide2/includes/molecules/candidates/candidate_secondary_box.html b/shared/templates/styleguide2/includes/molecules/candidates/candidate_secondary_box.html
index ac52a85f..218bd3cb 100644
--- a/shared/templates/styleguide2/includes/molecules/candidates/candidate_secondary_box.html
+++ b/shared/templates/styleguide2/includes/molecules/candidates/candidate_secondary_box.html
@@ -30,7 +30,7 @@
     >
       <h4
         class="text-xl font-bold w-64"
-      >{{ self.page.title }}</h4>
+      >{{ self.page.get_full_name }}</h4>
 
       <p class="lg:ml-6">
         {% if show_job and self.page.job %}
diff --git a/shared/templates/styleguide2/includes/organisms/candidates/candidate_primary_list.html b/shared/templates/styleguide2/includes/organisms/candidates/candidate_primary_list.html
index 8afe2b93..b8b09511 100644
--- a/shared/templates/styleguide2/includes/organisms/candidates/candidate_primary_list.html
+++ b/shared/templates/styleguide2/includes/organisms/candidates/candidate_primary_list.html
@@ -14,9 +14,9 @@
     {% firstof candidate.description candidate.page.perex as description %}
 
     {% if show_job %}
-      {% include "styleguide2/includes/molecules/candidates/candidate_primary_box.html" with name=candidate.page.title position=candidate.page.job description=description url=candidate.page.url candidate_image=resized_candidate_image %}
+      {% include "styleguide2/includes/molecules/candidates/candidate_primary_box.html" with name=candidate.page.get_full_name position=candidate.page.job description=description url=candidate.page.url candidate_image=resized_candidate_image %}
     {% else %}
-      {% include "styleguide2/includes/molecules/candidates/candidate_primary_box.html" with name=candidate.page.title position=candidate.page.position description=description url=candidate.page.url candidate_image=resized_candidate_image %}
+      {% include "styleguide2/includes/molecules/candidates/candidate_primary_box.html" with name=candidate.page.get_full_name position=candidate.page.position description=description url=candidate.page.url candidate_image=resized_candidate_image %}
     {% endif %}
   {% endfor %}
 </ul>
-- 
GitLab