summaryrefslogtreecommitdiff
path: root/ishtar_common/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'ishtar_common/utils.py')
-rw-r--r--ishtar_common/utils.py8
1 files changed, 8 insertions, 0 deletions
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