From c127e36d485b72cdcb567825ba7eb7e2a6f77783 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Valenta?= <git@imaniti.org>
Date: Fri, 14 Jul 2023 22:25:35 +0900
Subject: [PATCH] UI - shorten names by default

---
 contracts/models.py                                | 14 ++++++++++++++
 .../contracts/includes/contract_list.html          |  4 ++--
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/contracts/models.py b/contracts/models.py
index 1c1102f..bcd61d7 100644
--- a/contracts/models.py
+++ b/contracts/models.py
@@ -200,6 +200,13 @@ class Signee(
     def url(self) -> str:
         return reverse("contracts:view_signee", args=(self.id,))
 
+    @property
+    def shortened_name(self) -> str:
+        if len(self.name) > 25:
+            return self.name[:22] + "..."
+
+        return self.name
+
     @property
     def entity_has_public_address(self) -> bool:
         return self.entity_type in (
@@ -355,6 +362,13 @@ class Contractee(
     def url(self) -> str:
         return reverse("contracts:view_contractee", args=(self.id,))
 
+    @property
+    def shortened_name(self) -> str:
+        if len(self.name) > 25:
+            return self.name[:22] + "..."
+
+        return self.name
+
     def __str__(self) -> str:
         result = str(self.name)
 
diff --git a/contracts/templates/contracts/includes/contract_list.html b/contracts/templates/contracts/includes/contract_list.html
index e8bcf35..24a9794 100644
--- a/contracts/templates/contracts/includes/contract_list.html
+++ b/contracts/templates/contracts/includes/contract_list.html
@@ -61,9 +61,9 @@
                                         {% for signature in contract.signee_signatures.all %}
                                             <li class="flex">
                                                 {% if signature.signee.entity_type == signature.signee.EntityTypes.LEGAL_ENTITY or signature.signee.entity_type == signature.signee.EntityTypes.OTHER %}
-                                                    {% include "contracts/includes/tag.html" with url=signature.signee.url icon="ico--office" content=signature.signee.name public=contract.is_public %}
+                                                    {% include "contracts/includes/tag.html" with url=signature.signee.url icon="ico--office" content=signature.signee.shortened_name public=contract.is_public %}
                                                 {% else %}
-                                                    {% include "contracts/includes/tag.html" with url=signature.signee.url icon="ico--user" content=signature.signee.name public=contract.is_public %}
+                                                    {% include "contracts/includes/tag.html" with url=signature.signee.url icon="ico--user" content=signature.signee.shortened_name public=contract.is_public %}
                                                 {% endif %}
                                             </li>
                                         {% endfor %}
-- 
GitLab