def list_teams(self, request): current_user = endpoints.get_current_user() if current_user is None: raise endpoints.UnauthorizedException() organisation = Organisation.get_by_id(request.code_organisation) if organisation is None: raise endpoints.BadRequestException("Organisation %s does not exists" % request.code_organisation) if current_user.email() not in organisation.admins_mail: teams = Team.query(Team.users_mails == current_user.email(), ancestor=organisation.key).fetch() else: teams = Team.query(ancestor=organisation.key).fetch() return OrganisationConverter().convert_team_collection(teams)