team.go 670 B

1234567891011121314151617181920212223242526272829
  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. func ListTeams(c *context.APIContext) {
  13. org := c.Org.Organization
  14. if err := org.GetTeams(); err != nil {
  15. c.Error(500, "GetTeams", err)
  16. return
  17. }
  18. apiTeams := make([]*api.Team, len(org.Teams))
  19. for i := range org.Teams {
  20. apiTeams[i] = convert.ToTeam(org.Teams[i])
  21. }
  22. c.JSON(200, apiTeams)
  23. }