Change code in API EditTeam similar to EditTeamPost web interface
Signed-off-by: David Svantesson <davidsvantesson@gmail.com>
This commit is contained in:
parent
c1a2e266a4
commit
cfeb1c3226
1 changed files with 19 additions and 4 deletions
|
@ -183,12 +183,27 @@ func EditTeam(ctx *context.APIContext, form api.EditTeamOption) {
|
||||||
// "200":
|
// "200":
|
||||||
// "$ref": "#/responses/Team"
|
// "$ref": "#/responses/Team"
|
||||||
team := ctx.Org.Team
|
team := ctx.Org.Team
|
||||||
team.Name = form.Name
|
|
||||||
team.Description = form.Description
|
team.Description = form.Description
|
||||||
team.IncludesAllRepositories = form.IncludesAllRepositories
|
|
||||||
team.Authorize = models.ParseAccessMode(form.Permission)
|
|
||||||
unitTypes := models.FindUnitTypes(form.Units...)
|
unitTypes := models.FindUnitTypes(form.Units...)
|
||||||
|
|
||||||
|
isAuthChanged := false
|
||||||
|
isIncludeAllChanged := false
|
||||||
|
if !team.IsOwnerTeam() {
|
||||||
|
// Validate permission level.
|
||||||
|
auth := models.ParseAccessMode(form.Permission)
|
||||||
|
|
||||||
|
team.Name = form.Name
|
||||||
|
if team.Authorize != auth {
|
||||||
|
isAuthChanged = true
|
||||||
|
team.Authorize = auth
|
||||||
|
}
|
||||||
|
|
||||||
|
if team.IncludesAllRepositories != form.IncludesAllRepositories {
|
||||||
|
isIncludeAllChanged = true
|
||||||
|
team.IncludesAllRepositories = form.IncludesAllRepositories
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if team.Authorize < models.AccessModeOwner {
|
if team.Authorize < models.AccessModeOwner {
|
||||||
var units = make([]*models.TeamUnit, 0, len(form.Units))
|
var units = make([]*models.TeamUnit, 0, len(form.Units))
|
||||||
for _, tp := range unitTypes {
|
for _, tp := range unitTypes {
|
||||||
|
@ -200,7 +215,7 @@ func EditTeam(ctx *context.APIContext, form api.EditTeamOption) {
|
||||||
team.Units = units
|
team.Units = units
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := models.UpdateTeam(team, true, true); err != nil {
|
if err := models.UpdateTeam(team, isAuthChanged, isIncludeAllChanged); err != nil {
|
||||||
ctx.Error(500, "EditTeam", err)
|
ctx.Error(500, "EditTeam", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue