diff options
| author | Étienne Loks <etienne.loks@iggdrasil.net> | 2016-10-11 18:26:59 +0200 | 
|---|---|---|
| committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2016-10-11 18:26:59 +0200 | 
| commit | 253023f6c3480e75d1b9977ff2d2869af4262a29 (patch) | |
| tree | 96fee714f84d06390563bb928ed2a71497efbe5b /ishtar_common/models.py | |
| parent | ed8291ebd2c5613a9bddffd9380c9f61a08303dd (diff) | |
| download | Ishtar-253023f6c3480e75d1b9977ff2d2869af4262a29.tar.bz2 Ishtar-253023f6c3480e75d1b9977ff2d2869af4262a29.zip | |
Shortcut menu: limit simple menu to 100 entries by types
Diffstat (limited to 'ishtar_common/models.py')
| -rw-r--r-- | ishtar_common/models.py | 7 | 
1 files changed, 5 insertions, 2 deletions
| diff --git a/ishtar_common/models.py b/ishtar_common/models.py index 5b93b62a2..ba3d51172 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -235,7 +235,7 @@ class OwnPerms:          return cls.objects.filter(query).count()      @classmethod -    def get_owns(cls, user, replace_query={}): +    def get_owns(cls, user, replace_query={}, limit=None):          """          Get Own items          """ @@ -252,7 +252,10 @@ class OwnPerms:          q = cls.objects.filter(query)          if replace_query:              q = cls.objects.filter(**replace_query) -        items += list(q.order_by(*cls._meta.ordering).all()) +        if limit: +            items += list(q.order_by('-pk')[:limit]) +        else: +            items += list(q.order_by(*cls._meta.ordering).all())          return items | 
