diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2017-04-11 18:56:05 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2017-04-11 18:56:05 +0200 |
commit | dfd6fd2551a9cc54e6b69d4f5d4d4aa328b9cc7a (patch) | |
tree | 916cf36d9cd6d58e0c10e8711ee0c3f96c7bb221 /ishtar_common/models.py | |
parent | 987f84ca3aec153a6a9179e2b51083d7afaa9337 (diff) | |
parent | e3bdd4b6d2a32c010138e8f4581234d18cf51519 (diff) | |
download | Ishtar-dfd6fd2551a9cc54e6b69d4f5d4d4aa328b9cc7a.tar.bz2 Ishtar-dfd6fd2551a9cc54e6b69d4f5d4d4aa328b9cc7a.zip |
Merge branch 'master' into v0.9
Diffstat (limited to 'ishtar_common/models.py')
-rw-r--r-- | ishtar_common/models.py | 16 |
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 |