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 | 45c078a6d1960f34315c7ea83f1b15d275c054be (patch) | |
tree | aa5970043b874b009ecb9e8f9b9b810b5797248c /ishtar_common/utils.py | |
parent | a0167300b0fe9c39c4ce0f6260c7d014ee51dbcc (diff) | |
download | Ishtar-45c078a6d1960f34315c7ea83f1b15d275c054be.tar.bz2 Ishtar-45c078a6d1960f34315c7ea83f1b15d275c054be.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 |