Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Mar 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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