Browse Source

make sure units of a team are returned (#6379)

tags/v1.9.0-rc1
Lanre Adelowo 5 years ago
parent
commit
5c82ef098e
2 changed files with 10 additions and 0 deletions
  1. 5
    0
      models/org_team.go
  2. 5
    0
      routers/api/v1/org/team.go

+ 5
- 0
models/org_team.go View File

@@ -33,6 +33,11 @@ type Team struct {
Units []*TeamUnit `xorm:"-"`
}

// GetUnits return a list of available units for a team
func (t *Team) GetUnits() error {
return t.getUnits(x)
}

func (t *Team) getUnits(e Engine) (err error) {
if t.Units != nil {
return nil

+ 5
- 0
routers/api/v1/org/team.go View File

@@ -38,6 +38,11 @@ func ListTeams(ctx *context.APIContext) {

apiTeams := make([]*api.Team, len(org.Teams))
for i := range org.Teams {
if err := org.Teams[i].GetUnits(); err != nil {
ctx.Error(500, "GetUnits", err)
return
}

apiTeams[i] = convert.ToTeam(org.Teams[i])
}
ctx.JSON(200, apiTeams)

Loading…
Cancel
Save