diff options
author | Étienne Loks <etienne.loks@peacefrogs.net> | 2013-08-22 09:50:31 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@peacefrogs.net> | 2013-08-22 09:50:31 +0200 |
commit | 3554529456334662f035f41b9b7479c345439238 (patch) | |
tree | aa5970043b874b009ecb9e8f9b9b810b5797248c /ishtar_common/utils.py | |
parent | bc341909666384b666b7ba3ef36c44a4050b2138 (diff) | |
download | Ishtar-3554529456334662f035f41b9b7479c345439238.tar.bz2 Ishtar-3554529456334662f035f41b9b7479c345439238.zip |
More explicit label for operation and files (refs #1324)
Diffstat (limited to 'ishtar_common/utils.py')
-rw-r--r-- | ishtar_common/utils.py | 8 |
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 |