Skip to content

Commit 358ab99

Browse files
committed
fix api
1 parent 5478a4e commit 358ab99

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

routers/api/v1/org/team.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,21 @@ func attachTeamUnitsMap(team *organization.Team, unitsMap map[string]string) {
166166
}
167167
}
168168

169+
func attachAdminTeamUnits(team *organization.Team) {
170+
team.Units = make([]*organization.TeamUnit, 0, len(unit_model.AllRepoUnitTypes))
171+
for _, ut := range unit_model.AllRepoUnitTypes {
172+
up := perm.AccessModeAdmin
173+
if ut == unit_model.TypeExternalTracker || ut == unit_model.TypeExternalWiki {
174+
up = perm.AccessModeRead
175+
}
176+
team.Units = append(team.Units, &organization.TeamUnit{
177+
OrgID: team.OrgID,
178+
Type: ut,
179+
AccessMode: up,
180+
})
181+
}
182+
}
183+
169184
// CreateTeam api for create a team
170185
func CreateTeam(ctx *context.APIContext) {
171186
// swagger:operation POST /orgs/{org}/teams organization orgCreateTeam
@@ -213,6 +228,8 @@ func CreateTeam(ctx *context.APIContext) {
213228
ctx.Error(http.StatusInternalServerError, "getTeamUnits", errors.New("units permission should not be empty"))
214229
return
215230
}
231+
} else {
232+
attachAdminTeamUnits(team)
216233
}
217234

218235
if err := models.NewTeam(team); err != nil {
@@ -300,6 +317,8 @@ func EditTeam(ctx *context.APIContext) {
300317
} else if len(form.Units) > 0 {
301318
attachTeamUnits(team, form.Units)
302319
}
320+
} else {
321+
attachAdminTeamUnits(team)
303322
}
304323

305324
if err := models.UpdateTeam(team, isAuthChanged, isIncludeAllChanged); err != nil {

0 commit comments

Comments
 (0)