Skip to content

Commit

Permalink
make sure units of a team are returned (#6379) (#6381)
Browse files Browse the repository at this point in the history
  • Loading branch information
adelowo authored and techknowlogick committed Mar 19, 2019
1 parent 3934d9c commit 1681530
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions models/org_team.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions routers/api/v1/org/team.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 1681530

Please sign in to comment.