summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2025-03-20 14:31:50 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2025-03-20 16:07:34 +0100
commitcaf3138871b7cba6d76a83d4d7ae5123fddf1b8e (patch)
treec80b9fe57c4aff9ccfbb01af896e8e1bbe11ef49
parentb1d246d7045e07200b21049a714027dd72060f84 (diff)
downloadIshtar-caf3138871b7cba6d76a83d4d7ae5123fddf1b8e.tar.bz2
Ishtar-caf3138871b7cba6d76a83d4d7ae5123fddf1b8e.zip
🩹 sheet - geo: limit display of values
-rw-r--r--archaeological_operations/templates/ishtar/sheet_operation.html4
-rw-r--r--ishtar_common/models_common.py2
-rw-r--r--ishtar_common/templates/ishtar/blocks/sheet_geographic.html4
-rw-r--r--ishtar_common/templatetags/ishtar_helpers.py11
4 files changed, 16 insertions, 5 deletions
diff --git a/archaeological_operations/templates/ishtar/sheet_operation.html b/archaeological_operations/templates/ishtar/sheet_operation.html
index 4d078a998..ef9c9632a 100644
--- a/archaeological_operations/templates/ishtar/sheet_operation.html
+++ b/archaeological_operations/templates/ishtar/sheet_operation.html
@@ -151,9 +151,9 @@
{% if next or item.cached_towns_label %}
<span class="col-4"><strong>{% trans "Towns" %}</strong></span><span class="col-8">
{% if next %}
- {{ item|m2m_listing:'towns'|join:" ; "|default:'' }}
+ {{ item|m2m_listing:'towns'|join:" ; "|default:''|limit_label }}
{% else %}
- {{ item.cached_towns_label }}
+ {{ item.cached_towns_label|limit_label }}
{% endif %}
</span>
{% endif %}
diff --git a/ishtar_common/models_common.py b/ishtar_common/models_common.py
index e2495bcd5..d7b7c3e21 100644
--- a/ishtar_common/models_common.py
+++ b/ishtar_common/models_common.py
@@ -2519,7 +2519,7 @@ class GeoVectorData(Imported, OwnPerms):
@property
def source_label(self):
- return str(self.source)
+ return str(self.source or "-")
def display_coordinates_3d(self):
return self.display_coordinates(dim=3)
diff --git a/ishtar_common/templates/ishtar/blocks/sheet_geographic.html b/ishtar_common/templates/ishtar/blocks/sheet_geographic.html
index 6212c9573..d860293a8 100644
--- a/ishtar_common/templates/ishtar/blocks/sheet_geographic.html
+++ b/ishtar_common/templates/ishtar/blocks/sheet_geographic.html
@@ -18,9 +18,9 @@
<tr>
<td>{% if geo.id == geo_item.main_geodata_id %}<i class="fa fa-check-circle text-success" aria-hidden="true"></i>{% else %}&ndash;{% endif %}</td>
<td>{% if geo.data_type %}{{ geo.data_type }}{% else %}-{% endif %}</td>
- <td>{{ geo.source_label }}</td>
+ <td>{{ geo.source_label|limit_label:120 }}</td>
<td>{{ geo.geometry_type_label }}</td>
- <td>{{ geo.name }}</td>
+ <td>{{ geo.name|limit_label:120 }}</td>
<td>{% if geo.origin %}{{ geo.origin }}{% else %}-{% endif %}</td>
<td>{% if geo.provider %}{{ geo.provider }}{% else %}-{% endif %}</td>
<td>{% if geo.acquisition_date %}{{ geo.acquisition_date|date:"DATE_FORMAT"|default:"-" }}{% else %}-{% endif %}</td>
diff --git a/ishtar_common/templatetags/ishtar_helpers.py b/ishtar_common/templatetags/ishtar_helpers.py
index b668b8f0b..ece121a8e 100644
--- a/ishtar_common/templatetags/ishtar_helpers.py
+++ b/ishtar_common/templatetags/ishtar_helpers.py
@@ -133,3 +133,14 @@ def user_can_do(ishtar_user, permission):
@register.filter
def format_date(value):
return python_format_date(value)
+
+
+@register.filter
+def limit_label(value, limit=120):
+ value = str(value or "")
+ if len(value) <= limit:
+ return value
+ value = value.replace('"', '\\"')
+ return mark_safe(
+ f'<span title="{value}">{value[:(limit - 4)]} (...)</span>'
+ )