team.go 721 B

123456789101112131415161718192021222324252627282930
  1. // Copyright 2015 The Gogs Authors. All rights reserved.
  2. // Copyright 2018 Gitote. All rights reserved.
  3. //
  4. // This source code is licensed under the MIT license found in the
  5. // LICENSE file in the root directory of this source tree.
  6. package org
  7. import (
  8. "gitote/gitote/pkg/context"
  9. "gitote/gitote/routes/api/v1/convert"
  10. api "gitlab.com/gitote/go-gitote-client"
  11. )
  12. // ListTeams list all the teams of an organization
  13. func ListTeams(c *context.APIContext) {
  14. org := c.Org.Organization
  15. if err := org.GetTeams(); err != nil {
  16. c.Error(500, "GetTeams", err)
  17. return
  18. }
  19. apiTeams := make([]*api.Team, len(org.Teams))
  20. for i := range org.Teams {
  21. apiTeams[i] = convert.ToTeam(org.Teams[i])
  22. }
  23. c.JSON(200, apiTeams)
  24. }