diff options
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 | 
