diff --git a/models/org_team_test.go b/models/org_team_test.go index cf2c8be536..7881d8f4a2 100644 --- a/models/org_team_test.go +++ b/models/org_team_test.go @@ -84,7 +84,7 @@ func TestUpdateTeam(t *testing.T) { team.Name = "newName" team.Description = strings.Repeat("A long description!", 100) team.AccessMode = perm.AccessModeAdmin - assert.NoError(t, UpdateTeam(db.DefaultContext, team, true, false)) + assert.NoError(t, UpdateTeam(db.DefaultContext, team, "authorize")) team = unittest.AssertExistsAndLoadBean(t, &organization.Team{Name: "newName"}) assert.True(t, strings.HasPrefix(team.Description, "A long description!")) @@ -103,7 +103,7 @@ func TestUpdateTeam2(t *testing.T) { team.LowerName = "owners" team.Name = "Owners" team.Description = strings.Repeat("A long description!", 100) - err := UpdateTeam(db.DefaultContext, team, true, false) + err := UpdateTeam(db.DefaultContext, team, "authorize") assert.True(t, organization.IsErrTeamAlreadyExist(err)) unittest.CheckConsistencyFor(t, &organization.Team{ID: team.ID}) diff --git a/modules/structs/org_team.go b/modules/structs/org_team.go index 0db38c87ca..e906a51ba3 100644 --- a/modules/structs/org_team.go +++ b/modules/structs/org_team.go @@ -44,7 +44,7 @@ type EditTeamOption struct { Description *string `json:"description" binding:"MaxSize(255)"` IncludesAllRepositories *bool `json:"includes_all_repositories"` // enum: read,write,admin - Permission string `json:"permission" binding:"` + Permission string `json:"permission" binding:"Required;In(read,write,admin)"` // example: ["repo.code","repo.issues","repo.ext_issues","repo.wiki","repo.pulls","repo.releases","repo.projects","repo.ext_wiki"] // Deprecated: This variable should be replaced by UnitsMap and will be dropped in later versions. Units []string `json:"units"` diff --git a/services/forms/org.go b/services/forms/org.go index 304432ef2d..a6df8aadee 100644 --- a/services/forms/org.go +++ b/services/forms/org.go @@ -57,7 +57,7 @@ func (f *UpdateOrgSettingForm) Validate(req *http.Request, errs binding.Errors) type CreateTeamForm struct { TeamName string `binding:"Required;AlphaDashDot;MaxSize(255)"` Description string `binding:"MaxSize(255)"` - Permission string `binding:"Required;In(admin, read)"` + Permission string `binding:"Required;In(read,write,admin)"` RepoAccess string `binding:"Required;In(specified, all)"` CanCreateOrgRepo bool } diff --git a/services/org/team.go b/services/org/team.go index 82951aa4e2..f4b0d76324 100644 --- a/services/org/team.go +++ b/services/org/team.go @@ -24,7 +24,7 @@ type UpdateTeamOptions struct { func UpdateTeam(ctx context.Context, team *org_model.Team, opts UpdateTeamOptions) error { var changedCols []string - newAccessMode := perm.AccessModeRead + var newAccessMode perm.AccessMode if opts.IsAdmin { newAccessMode = perm.AccessModeAdmin } else { diff --git a/services/repository/create_test.go b/services/repository/create_test.go index 41e6b615db..bd8d9e0efa 100644 --- a/services/repository/create_test.go +++ b/services/repository/create_test.go @@ -111,7 +111,7 @@ func TestIncludesAllRepositoriesTeams(t *testing.T) { teams[4].IncludesAllRepositories = true teamRepos[4] = repoIDs for i, team := range teams { - assert.NoError(t, models.UpdateTeam(db.DefaultContext, team, false, true), "%s: UpdateTeam", team.Name) + assert.NoError(t, models.UpdateTeam(db.DefaultContext, team, "includes_all_repositories"), "%s: UpdateTeam", team.Name) testTeamRepositories(team.ID, teamRepos[i]) }