summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2017-04-09 20:05:44 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2017-04-09 20:05:44 +0200
commit11e03ef2e267a79dcd5b96bc170c852fc4d0dc23 (patch)
tree642f6fe5c113b9be27423e88c6116786d6e05474
parent73a042daf57147a394bd6e7c6cd6f465cede507c (diff)
downloadIshtar-11e03ef2e267a79dcd5b96bc170c852fc4d0dc23.tar.bz2
Ishtar-11e03ef2e267a79dcd5b96bc170c852fc4d0dc23.zip
Fix hiearchical display of types
-rw-r--r--ishtar_common/models.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/ishtar_common/models.py b/ishtar_common/models.py
index 988254359..83cb25d46 100644
--- a/ishtar_common/models.py
+++ b/ishtar_common/models.py
@@ -568,7 +568,7 @@ class GeneralType(Cached, models.Model):
@classmethod
def _get_childs(cls, item, dct, prefix=0, instances=False, exclude=[],
- is_last=False):
+ is_last=False, last_of=[]):
prefix += 1
dct['parent'] = item
childs = cls.objects.filter(**dct)
@@ -580,6 +580,7 @@ class GeneralType(Cached, models.Model):
child_lst = childs.all()
total = len(child_lst)
for idx, child in enumerate(child_lst):
+ mylast_of = last_of[:]
if instances:
child.rank = prefix
lst.append(child)
@@ -594,15 +595,24 @@ class GeneralType(Cached, models.Model):
else:
p += cls.PREFIX_MEDIUM
elif is_last:
- p += cls.PREFIX_EMPTY
+ if mylast_of:
+ clast = mylast_of.pop(0)
+ if clast:
+ p += cls.PREFIX_EMPTY
+ else:
+ p += cls.PREFIX
+ else:
+ p += cls.PREFIX_EMPTY
else:
p += cls.PREFIX
lst.append((
child.pk, SafeUnicode(p + unicode(_(unicode(child))))
))
+ clast_of = last_of[:]
+ clast_of.append(idx + 1 == total)
for sub_child in cls._get_childs(
child, dct, prefix, instances, exclude=exclude,
- is_last=((idx + 1) == total)):
+ is_last=((idx + 1) == total), last_of=clast_of):
lst.append(sub_child)
return lst