From: Scott Baker Date: Fri, 6 Jun 2014 23:09:51 +0000 (-0700) Subject: fix select_by_acl to return a queryset X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=cb95fdea5aba8d5af12e33a342727acc34fb8beb;p=plstackapi.git fix select_by_acl to return a queryset --- diff --git a/planetstack/core/models/site.py b/planetstack/core/models/site.py index 072b288..b86b7c4 100644 --- a/planetstack/core/models/site.py +++ b/planetstack/core/models/site.py @@ -116,13 +116,15 @@ class Deployment(PlCoreBase): return False - def select_by_acl(self, user): - acl = self.get_acl() - result = [] + @staticmethod + def select_by_acl(user): + ids = [] for deployment in Deployment.objects.all(): + acl = deployment.get_acl() if acl.test(user): - result.append(deployment) - return result + ids.append(deployment.id) + + return Deployment.objects.filter(id__in=ids) def __unicode__(self): return u'%s' % (self.name)