2016-03-21 12:53:04 -04:00
|
|
|
// Copyright 2016 The Gogs Authors. All rights reserved.
|
|
|
|
|
// Use of this source code is governed by a MIT-style
|
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
|
|
package org
|
|
|
|
|
|
|
|
|
|
import (
|
2018-05-27 08:53:48 +08:00
|
|
|
api "github.com/gogs/go-gogs-client"
|
2016-03-21 12:53:04 -04:00
|
|
|
|
2019-10-23 23:03:17 -07:00
|
|
|
"gogs.io/gogs/pkg/context"
|
|
|
|
|
"gogs.io/gogs/routes/api/v1/convert"
|
2016-03-21 12:53:04 -04:00
|
|
|
)
|
|
|
|
|
|
2017-06-03 07:26:09 -04:00
|
|
|
func ListTeams(c *context.APIContext) {
|
|
|
|
|
org := c.Org.Organization
|
2016-03-21 12:53:04 -04:00
|
|
|
if err := org.GetTeams(); err != nil {
|
2017-06-03 07:26:09 -04:00
|
|
|
c.Error(500, "GetTeams", err)
|
2016-03-21 12:53:04 -04:00
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
apiTeams := make([]*api.Team, len(org.Teams))
|
|
|
|
|
for i := range org.Teams {
|
|
|
|
|
apiTeams[i] = convert.ToTeam(org.Teams[i])
|
|
|
|
|
}
|
2017-06-03 07:26:09 -04:00
|
|
|
c.JSON(200, apiTeams)
|
2016-03-21 12:53:04 -04:00
|
|
|
}
|