From 16815306ad97488b35b7d6786fac24dea3907610 Mon Sep 17 00:00:00 2001 From: Lanre Adelowo Date: Tue, 19 Mar 2019 23:40:54 +0100 Subject: [PATCH] make sure units of a team are returned (#6379) (#6381) --- models/org_team.go | 5 +++++ routers/api/v1/org/team.go | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/models/org_team.go b/models/org_team.go index 22fb6eae2..40fdeaa75 100644 --- a/models/org_team.go +++ b/models/org_team.go @@ -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 diff --git a/routers/api/v1/org/team.go b/routers/api/v1/org/team.go index a1916db00..de5e9e7f1 100644 --- a/routers/api/v1/org/team.go +++ b/routers/api/v1/org/team.go @@ -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)