def add_team(self, request): current_user = endpoints.get_current_user() organisation = Organisation.get_by_id(request.code_organisation) if current_user is None or current_user.email() not in organisation.admins_mail: raise endpoints.UnauthorizedException(message="Team creation is reserved to admins") team = Team( name=request.name, parent=organisation.key ) team.put() organisation.teams.append(team.key) organisation.put() return OrganisationConverter().convert_team(team)