From 3554529456334662f035f41b9b7479c345439238 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Thu, 22 Aug 2013 09:50:31 +0200 Subject: More explicit label for operation and files (refs #1324) --- ishtar_common/utils.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'ishtar_common/utils.py') diff --git a/ishtar_common/utils.py b/ishtar_common/utils.py index 50f4a6b41..d5fc37276 100644 --- a/ishtar_common/utils.py +++ b/ishtar_common/utils.py @@ -17,6 +17,8 @@ # See the file COPYING for details. +from django.utils.translation import ugettext + def cached_label_changed(sender, **kwargs): if not kwargs.get('instance'): return @@ -25,3 +27,9 @@ def cached_label_changed(sender, **kwargs): if lbl != instance.cached_label: instance.cached_label = lbl instance.save() + +SHORTIFY_STR = ugettext(" (...)") +def shortify(lbl, number=20): + if len(lbl) <= number: + return lbl + return lbl[:number-len(SHORTIFY_STR)] + SHORTIFY_STR -- cgit v1.2.3