team.go 727 B

12345678910111213141516171819202122232425262728293031
  1. // Copyright 2016 The Gogs Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package org
  5. import (
  6. api "github.com/gogits/go-gogs-client"
  7. "github.com/gogits/gogs/modules/context"
  8. "github.com/gogits/gogs/routers/api/v1/convert"
  9. "github.com/gogits/gogs/routers/api/v1/user"
  10. )
  11. func ListTeams(ctx *context.APIContext) {
  12. org := user.GetUserByParamsName(ctx, ":orgname")
  13. if ctx.Written() {
  14. return
  15. }
  16. if err := org.GetTeams(); err != nil {
  17. ctx.Error(500, "GetTeams", err)
  18. return
  19. }
  20. apiTeams := make([]*api.Team, len(org.Teams))
  21. for i := range org.Teams {
  22. apiTeams[i] = convert.ToTeam(org.Teams[i])
  23. }
  24. ctx.JSON(200, apiTeams)
  25. }