diff options
Diffstat (limited to 'ishtar_common')
-rw-r--r-- | ishtar_common/models_common.py | 2 | ||||
-rw-r--r-- | ishtar_common/templates/ishtar/blocks/sheet_geographic.html | 4 | ||||
-rw-r--r-- | ishtar_common/templatetags/ishtar_helpers.py | 11 |
3 files changed, 14 insertions, 3 deletions
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 %}–{% 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>' + ) |