diff options
| 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 | 
| commit | 2d26023da0bc0929e748f3fa13deac12479003b9 (patch) | |
| tree | 642f6fe5c113b9be27423e88c6116786d6e05474 /ishtar_common/models.py | |
| parent | 6a4984ceb1649a74ccfbbae36884ff40e4a10ac4 (diff) | |
| download | Ishtar-2d26023da0bc0929e748f3fa13deac12479003b9.tar.bz2 Ishtar-2d26023da0bc0929e748f3fa13deac12479003b9.zip  | |
Fix hiearchical display of types
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  | 
