'Return a list of teams this user is an owner or member of.'

def get_teams(self, only_approved=False, only_open=False, cursor=None):

    teams = (cursor or self.db).all(u'\n                                                SELECT    teams.*::teams    FROM    teams    WHERE    owner=%s\n\n                                                UNION\n\n                                                SELECT    teams.*::teams    FROM    teams    WHERE    id    IN    (\n                                                                SELECT    team_id    FROM    current_takes    WHERE    participant_id=%s\n                                                )\n                                ', (self.username, self.id))
    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
