[damned-lies] Fix the team roles query



commit 0483b2c569a608f001b5ded9325ab89b648bf773
Author: Claude Paroz <claude 2xlibre net>
Date:   Fri Jan 18 18:36:55 2013 +0100

    Fix the team roles query

 teams/models.py |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)
---
diff --git a/teams/models.py b/teams/models.py
index 9569dae..83661a9 100644
--- a/teams/models.py
+++ b/teams/models.py
@@ -135,9 +135,11 @@ class Team(models.Model):
         try:
             return self.roles[role]
         except KeyError:
-            members = Person.objects.filter(role__team__id=self.id, role__role=role)
             if only_active:
-                members = members.filter(role__is_active=True)
+                members = Person.objects.filter(role__team__id=self.id,
+                    role__role=role, role__is_active=True)
+            else:
+                members = Person.objects.filter(role__team__id=self.id, role__role=role)
             return list(members)
 
     def get_coordinators(self):
@@ -159,9 +161,11 @@ class Team(models.Model):
             for role in roles:
                 members += self.roles[role]
         except KeyError:
-            members = Person.objects.filter(role__team__id=self.id, role__role__in=roles)
             if only_active:
-                members = members.filter(role__is_active=True)
+                members = Person.objects.filter(role__team__id=self.id,
+                    role__role__in=roles, role__is_active=True)
+            else:
+                members = Person.objects.filter(role__team__id=self.id, role__role__in=roles)
         return list(members)
 
     def get_committers(self):



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]