summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--archaeological_files/models.py4
-rw-r--r--ishtar_common/utils.py6
2 files changed, 8 insertions, 2 deletions
diff --git a/archaeological_files/models.py b/archaeological_files/models.py
index a01a6f99e..93cbdff13 100644
--- a/archaeological_files/models.py
+++ b/archaeological_files/models.py
@@ -368,11 +368,13 @@ class File(BaseHistorizedItem, OwnPerms, ValueGetter, ShortMenuItem,
return Parcel.grouped_parcels(list(self.parcels.all()))
def get_town_label(self):
- lbl = unicode(_('Intercommunal'))
+ lbl = unicode(_(u'Multi-town'))
if self.main_town:
lbl = self.main_town.name
elif self.towns.count() == 1:
lbl = self.towns.all()[0].name
+ elif self.towns.count() == 0:
+ lbl = unicode(_(u"No town"))
return lbl
def get_department(self):
diff --git a/ishtar_common/utils.py b/ishtar_common/utils.py
index f50031d5d..65bd1ee15 100644
--- a/ishtar_common/utils.py
+++ b/ishtar_common/utils.py
@@ -21,6 +21,7 @@ from django.core.cache import cache
from django.utils.translation import ugettext
from django.template.defaultfilters import slugify
+
def get_cache(cls, extra_args=[]):
cache_key = cls.__name__
for arg in extra_args:
@@ -36,6 +37,7 @@ def get_cache(cls, extra_args=[]):
cache_key = slugify(cache_key)
return cache_key, cache.get(cache_key)
+
def cached_label_changed(sender, **kwargs):
if not kwargs.get('instance'):
return
@@ -46,7 +48,9 @@ def cached_label_changed(sender, **kwargs):
instance.save()
SHORTIFY_STR = ugettext(" (...)")
+
+
def shortify(lbl, number=20):
if len(lbl) <= number:
return lbl
- return lbl[:number-len(SHORTIFY_STR)] + SHORTIFY_STR
+ return lbl[:number - len(SHORTIFY_STR)] + SHORTIFY_STR