diff --git a/gratipay/models/participant/__init__.py b/gratipay/models/participant/__init__.py index 2786ba53e6..c6dd899087 100644 --- a/gratipay/models/participant/__init__.py +++ b/gratipay/models/participant/__init__.py @@ -1077,13 +1077,11 @@ def profile_url(self): return '{base_url}/{username}/'.format(**locals()) - def get_teams(self, only_approved=False, cursor=None): + def get_teams(self, only_approved=False, only_open=False, cursor=None): """Return a list of teams this user is an owner or member of. """ teams = (cursor or self.db).all(""" - SELECT teams.*::teams FROM teams WHERE - owner=%s AND - NOT is_closed + SELECT teams.*::teams FROM teams WHERE owner=%s UNION @@ -1094,6 +1092,8 @@ def get_teams(self, only_approved=False, cursor=None): ) if only_approved: teams = [t for t in teams if t.is_approved] + if only_open: + teams = [t for t in teams if not t.is_closed] return teams diff --git a/templates/team-listing.html b/templates/team-listing.html index 51807d940e..0aca8a9e18 100644 --- a/templates/team-listing.html +++ b/templates/team-listing.html @@ -1,16 +1,16 @@ -{% set approved_teams = participant.get_teams(only_approved=True) %} +{% set approved_open_teams = participant.get_teams(only_approved=True, only_open=True) %} -{% if (user.ADMIN or user.participant == participant) and approved_teams %} +{% if (user.ADMIN or user.participant == participant) and approved_open_teams %}