[damned-lies] Reverted is_coordinator semantic for team=None



commit 3efc66291c69f7848bf4c5cfbf916a66be6b75e8
Author: Claude Paroz <claude 2xlibre net>
Date:   Sat Mar 30 15:33:21 2013 +0100

    Reverted is_coordinator semantic for team=None
    
    People is_* methods had already an accepted semantic when the
    team argument was None (languages with no team).

 people/models.py   |   14 +++++++-------
 stats/views.py     |    2 +-
 vertimus/models.py |    3 ++-
 3 files changed, 10 insertions(+), 9 deletions(-)
---
diff --git a/people/models.py b/people/models.py
index 3e9e99f..8a5bc5f 100644
--- a/people/models.py
+++ b/people/models.py
@@ -138,37 +138,37 @@ class Person(User):
 
     def is_coordinator(self, team):
         """
-        If team is provided, tell if current Person is coordinator of that team.
-        If not provided (None), tell if current Person is coordinator of at least one team.
+        If team is a Team instance, tell if current Person is coordinator of that team.
+        If team = 'any', tell if current Person is coordinator of at least one team.
         """
-        if team is None:
+        if team == 'any':
             return self.role_set.filter(role='coordinator').exists()
         else:
             try:
                 self.role_set.get(team__id=team.id, role='coordinator')
                 return True
-            except ObjectDoesNotExist:
+            except (ObjectDoesNotExist, AttributeError):
                 return False
 
     def is_committer(self, team):
         try:
             self.role_set.get(team__id=team.id, role__in=['committer', 'coordinator'])
             return True
-        except ObjectDoesNotExist:
+        except (ObjectDoesNotExist, AttributeError):
             return False
 
     def is_reviewer(self, team):
         try:
             self.role_set.get(team__id=team.id, role__in=['reviewer', 'committer', 'coordinator'])
             return True
-        except ObjectDoesNotExist:
+        except (ObjectDoesNotExist, AttributeError):
             return False
 
     def is_translator(self, team):
         try:
             self.role_set.get(team__id=team.id)
             return True
-        except ObjectDoesNotExist:
+        except (ObjectDoesNotExist, AttributeError):
             return False
 
     def is_maintainer_of(self, module):
diff --git a/stats/views.py b/stats/views.py
index 0ce670f..59baa36 100644
--- a/stats/views.py
+++ b/stats/views.py
@@ -313,6 +313,6 @@ def can_refresh_branch(user):
     if user.has_perm('stats.change_module'):
         return True
     person = Person.get_by_user(user)
-    if person.is_coordinator(team=None):
+    if person.is_coordinator(team='any'):
         return True
     return False
diff --git a/vertimus/models.py b/vertimus/models.py
index c70db0e..be47631 100644
--- a/vertimus/models.py
+++ b/vertimus/models.py
@@ -128,7 +128,8 @@ class StateNone(State):
     def get_available_actions(self, person):
         action_names = []
 
-        if person.is_translator(self.language.team) or person.is_maintainer_of(self.branch.module):
+        if ((self.language.team and person.is_translator(self.language.team))
+                or person.is_maintainer_of(self.branch.module)):
             action_names = ['RT']
 
         return self._get_available_actions(person, action_names)


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