diff --git a/integrations/api_team_test.go b/integrations/api_team_test.go index 8eb18f4e90..3832abdc5f 100644 --- a/integrations/api_team_test.go +++ b/integrations/api_team_test.go @@ -55,35 +55,35 @@ func TestAPITeam(t *testing.T) { // Create team. teamToCreate := &api.CreateTeamOption{ - Name: "team1", - Description: "team one", - IsAllRepositories: true, - Permission: "write", - Units: []string{"repo.code", "repo.issues"}, + Name: "team1", + Description: "team one", + IncludesAllRepositories: true, + Permission: "write", + Units: []string{"repo.code", "repo.issues"}, } req = NewRequestWithJSON(t, "POST", fmt.Sprintf("/api/v1/orgs/%s/teams?token=%s", org.Name, token), teamToCreate) resp = session.MakeRequest(t, req, http.StatusCreated) DecodeJSON(t, resp, &apiTeam) - checkTeamResponse(t, &apiTeam, teamToCreate.Name, teamToCreate.Description, teamToCreate.IsAllRepositories, + checkTeamResponse(t, &apiTeam, teamToCreate.Name, teamToCreate.Description, teamToCreate.IncludesAllRepositories, teamToCreate.Permission, teamToCreate.Units) - checkTeamBean(t, apiTeam.ID, teamToCreate.Name, teamToCreate.Description, teamToCreate.IsAllRepositories, + checkTeamBean(t, apiTeam.ID, teamToCreate.Name, teamToCreate.Description, teamToCreate.IncludesAllRepositories, teamToCreate.Permission, teamToCreate.Units) teamID := apiTeam.ID // Edit team. teamToEdit := &api.EditTeamOption{ - Name: "teamone", - Description: "team 1", - IsAllRepositories: false, - Permission: "admin", - Units: []string{"repo.code", "repo.pulls", "repo.releases"}, + Name: "teamone", + Description: "team 1", + IncludesAllRepositories: false, + Permission: "admin", + Units: []string{"repo.code", "repo.pulls", "repo.releases"}, } req = NewRequestWithJSON(t, "PATCH", fmt.Sprintf("/api/v1/teams/%d?token=%s", teamID, token), teamToEdit) resp = session.MakeRequest(t, req, http.StatusOK) DecodeJSON(t, resp, &apiTeam) - checkTeamResponse(t, &apiTeam, teamToEdit.Name, teamToEdit.Description, teamToEdit.IsAllRepositories, + checkTeamResponse(t, &apiTeam, teamToEdit.Name, teamToEdit.Description, teamToEdit.IncludesAllRepositories, teamToEdit.Permission, teamToEdit.Units) - checkTeamBean(t, apiTeam.ID, teamToEdit.Name, teamToEdit.Description, teamToEdit.IsAllRepositories, + checkTeamBean(t, apiTeam.ID, teamToEdit.Name, teamToEdit.Description, teamToEdit.IncludesAllRepositories, teamToEdit.Permission, teamToEdit.Units) // Read team. @@ -91,7 +91,7 @@ func TestAPITeam(t *testing.T) { req = NewRequestf(t, "GET", "/api/v1/teams/%d?token="+token, teamID) resp = session.MakeRequest(t, req, http.StatusOK) DecodeJSON(t, resp, &apiTeam) - checkTeamResponse(t, &apiTeam, teamRead.Name, teamRead.Description, teamRead.IsAllRepositories, + checkTeamResponse(t, &apiTeam, teamRead.Name, teamRead.Description, teamRead.IncludesAllRepositories, teamRead.Authorize.String(), teamRead.GetUnitNames()) // Delete team. @@ -100,18 +100,18 @@ func TestAPITeam(t *testing.T) { models.AssertNotExistsBean(t, &models.Team{ID: teamID}) } -func checkTeamResponse(t *testing.T, apiTeam *api.Team, name, description string, isAllRepositories bool, permission string, units []string) { +func checkTeamResponse(t *testing.T, apiTeam *api.Team, name, description string, includesAllRepositories bool, permission string, units []string) { assert.Equal(t, name, apiTeam.Name, "name") assert.Equal(t, description, apiTeam.Description, "description") - assert.Equal(t, isAllRepositories, apiTeam.IsAllRepositories, "isAllRepositories") + assert.Equal(t, includesAllRepositories, apiTeam.IncludesAllRepositories, "includesAllRepositories") assert.Equal(t, permission, apiTeam.Permission, "permission") sort.StringSlice(units).Sort() sort.StringSlice(apiTeam.Units).Sort() assert.EqualValues(t, units, apiTeam.Units, "units") } -func checkTeamBean(t *testing.T, id int64, name, description string, isAllRepositories bool, permission string, units []string) { +func checkTeamBean(t *testing.T, id int64, name, description string, includesAllRepositories bool, permission string, units []string) { team := models.AssertExistsAndLoadBean(t, &models.Team{ID: id}).(*models.Team) assert.NoError(t, team.GetUnits(), "GetUnits") - checkTeamResponse(t, convert.ToTeam(team), name, description, isAllRepositories, permission, units) + checkTeamResponse(t, convert.ToTeam(team), name, description, includesAllRepositories, permission, units) } diff --git a/models/migrations/migrations.go b/models/migrations/migrations.go index e5f08365fc..181aa3ad75 100644 --- a/models/migrations/migrations.go +++ b/models/migrations/migrations.go @@ -224,7 +224,7 @@ var migrations = []Migration{ // v84 -> v85 NewMigration("add table to store original imported gpg keys", addGPGKeyImport), // v85 -> v86 - NewMigration("add is_all_repositories to teams", addTeamIsAllRepositories), + NewMigration("add includes_all_repositories to teams", addTeamIncludesAllRepositories), } // Migrate database to current version diff --git a/models/migrations/v85.go b/models/migrations/v85.go index ef021b1877..70a32f6566 100644 --- a/models/migrations/v85.go +++ b/models/migrations/v85.go @@ -8,18 +8,18 @@ import ( "github.com/go-xorm/xorm" ) -func addTeamIsAllRepositories(x *xorm.Engine) error { +func addTeamIncludesAllRepositories(x *xorm.Engine) error { type Team struct { - ID int64 `xorm:"pk autoincr"` - IsAllRepositories bool `xorm:"NOT NULL DEFAULT false"` + ID int64 `xorm:"pk autoincr"` + IncludesAllRepositories bool `xorm:"NOT NULL DEFAULT false"` } if err := x.Sync2(new(Team)); err != nil { return err } - _, err := x.Exec("UPDATE `team` SET `is_all_repositories` = ? WHERE `name`=?", + _, err := x.Exec("UPDATE `team` SET `includes_all_repositories` = ? WHERE `name`=?", true, "Owners") return err } diff --git a/models/org.go b/models/org.go index 182d96f784..b3d51f7946 100644 --- a/models/org.go +++ b/models/org.go @@ -152,12 +152,12 @@ func CreateOrganization(org, owner *User) (err error) { // Create default owner team. t := &Team{ - OrgID: org.ID, - LowerName: strings.ToLower(ownerTeamName), - Name: ownerTeamName, - Authorize: AccessModeOwner, - NumMembers: 1, - IsAllRepositories: true, + OrgID: org.ID, + LowerName: strings.ToLower(ownerTeamName), + Name: ownerTeamName, + Authorize: AccessModeOwner, + NumMembers: 1, + IncludesAllRepositories: true, } if _, err = sess.Insert(t); err != nil { return fmt.Errorf("insert owner team: %v", err) diff --git a/models/org_team.go b/models/org_team.go index 07de1566b6..f88d953b90 100644 --- a/models/org_team.go +++ b/models/org_team.go @@ -21,18 +21,18 @@ const ownerTeamName = "Owners" // Team represents a organization team. type Team struct { - ID int64 `xorm:"pk autoincr"` - OrgID int64 `xorm:"INDEX"` - LowerName string - Name string - Description string - Authorize AccessMode - Repos []*Repository `xorm:"-"` - Members []*User `xorm:"-"` - NumRepos int - NumMembers int - Units []*TeamUnit `xorm:"-"` - IsAllRepositories bool `xorm:"NOT NULL DEFAULT false"` + ID int64 `xorm:"pk autoincr"` + OrgID int64 `xorm:"INDEX"` + LowerName string + Name string + Description string + Authorize AccessMode + Repos []*Repository `xorm:"-"` + Members []*User `xorm:"-"` + NumRepos int + NumMembers int + Units []*TeamUnit `xorm:"-"` + IncludesAllRepositories bool `xorm:"NOT NULL DEFAULT false"` } // ColorFormat provides a basic color format for a Team @@ -247,7 +247,7 @@ func (t *Team) RemoveRepository(repoID int64) error { return nil } - if t.IsAllRepositories { + if t.IncludesAllRepositories { return nil } @@ -349,7 +349,7 @@ func NewTeam(t *Team) (err error) { } // Add all repositories to the team if it has access to all of them. - if t.IsAllRepositories { + if t.IncludesAllRepositories { err = t.addAllRepositories(sess) if err != nil { return fmt.Errorf("addAllRepositories: %v", err) @@ -463,7 +463,7 @@ func UpdateTeam(t *Team, authChanged bool) (err error) { } // Add all repositories to the team if it has access to all of them. - if t.IsAllRepositories { + if t.IncludesAllRepositories { err = t.addAllRepositories(sess) if err != nil { return fmt.Errorf("addAllRepositories: %v", err) diff --git a/models/org_team_test.go b/models/org_team_test.go index d961445a7a..11db52e5f2 100644 --- a/models/org_team_test.go +++ b/models/org_team_test.go @@ -397,7 +397,7 @@ func TestAllRepositoriesTeams(t *testing.T) { // Check Owner team. ownerTeam, err := org.GetOwnerTeam() assert.NoError(t, err, "GetOwnerTeam") - assert.True(t, ownerTeam.IsAllRepositories, "Owner team is all repositories") + assert.True(t, ownerTeam.IncludesAllRepositories, "Owner team includes all repositories") // Create repos. repoIds := make([]int64, 0) @@ -413,28 +413,28 @@ func TestAllRepositoriesTeams(t *testing.T) { teams := []*Team{ ownerTeam, { - OrgID: org.ID, - Name: "team one", - Authorize: AccessModeRead, - IsAllRepositories: true, + OrgID: org.ID, + Name: "team one", + Authorize: AccessModeRead, + IncludesAllRepositories: true, }, { - OrgID: org.ID, - Name: "team 2", - Authorize: AccessModeRead, - IsAllRepositories: false, + OrgID: org.ID, + Name: "team 2", + Authorize: AccessModeRead, + IncludesAllRepositories: false, }, { - OrgID: org.ID, - Name: "team three", - Authorize: AccessModeWrite, - IsAllRepositories: true, + OrgID: org.ID, + Name: "team three", + Authorize: AccessModeWrite, + IncludesAllRepositories: true, }, { - OrgID: org.ID, - Name: "team 4", - Authorize: AccessModeWrite, - IsAllRepositories: false, + OrgID: org.ID, + Name: "team 4", + Authorize: AccessModeWrite, + IncludesAllRepositories: false, }, } repoCounts := []int{3, 3, 0, 3, 0} @@ -447,8 +447,8 @@ func TestAllRepositoriesTeams(t *testing.T) { } // Update teams and check repo count. - teams[3].IsAllRepositories = false - teams[4].IsAllRepositories = true + teams[3].IncludesAllRepositories = false + teams[4].IncludesAllRepositories = true repoCounts[4] = 3 for i, team := range teams { assert.NoError(t, UpdateTeam(team, false), "team %d: UpdateTeam", i) diff --git a/models/repo.go b/models/repo.go index 9bf1430347..d406e69e1c 100644 --- a/models/repo.go +++ b/models/repo.go @@ -1361,7 +1361,7 @@ func createRepository(e *xorm.Session, doer, u *User, repo *Repository) (err err return fmt.Errorf("GetTeams: %v", err) } for _, t := range u.Teams { - if t.IsAllRepositories { + if t.IncludesAllRepositories { if err := t.addRepository(e, repo); err != nil { return fmt.Errorf("addRepository: %v", err) } diff --git a/modules/auth/org.go b/modules/auth/org.go index 25963a5a07..31c46eb199 100644 --- a/modules/auth/org.go +++ b/modules/auth/org.go @@ -56,11 +56,11 @@ func (f *UpdateOrgSettingForm) Validate(ctx *macaron.Context, errs binding.Error // CreateTeamForm form for creating team type CreateTeamForm struct { - TeamName string `binding:"Required;AlphaDashDot;MaxSize(30)"` - Description string `binding:"MaxSize(255)"` - Permission string - Units []models.UnitType - IsAllRepositories bool + TeamName string `binding:"Required;AlphaDashDot;MaxSize(30)"` + Description string `binding:"MaxSize(255)"` + Permission string + Units []models.UnitType + IncludesAllRepositories bool } // Validate validates the fields diff --git a/routers/api/v1/convert/convert.go b/routers/api/v1/convert/convert.go index 7d813b5c76..7acd2b4685 100644 --- a/routers/api/v1/convert/convert.go +++ b/routers/api/v1/convert/convert.go @@ -219,12 +219,12 @@ func ToOrganization(org *models.User) *api.Organization { // ToTeam convert models.Team to api.Team func ToTeam(team *models.Team) *api.Team { return &api.Team{ - ID: team.ID, - Name: team.Name, - Description: team.Description, - IsAllRepositories: team.IsAllRepositories, - Permission: team.Authorize.String(), - Units: team.GetUnitNames(), + ID: team.ID, + Name: team.Name, + Description: team.Description, + IncludesAllRepositories: team.IncludesAllRepositories, + Permission: team.Authorize.String(), + Units: team.GetUnitNames(), } } diff --git a/routers/api/v1/org/team.go b/routers/api/v1/org/team.go index 0b5022f8c1..fa1ae1ad30 100644 --- a/routers/api/v1/org/team.go +++ b/routers/api/v1/org/team.go @@ -126,11 +126,11 @@ func CreateTeam(ctx *context.APIContext, form api.CreateTeamOption) { // "201": // "$ref": "#/responses/Team" team := &models.Team{ - OrgID: ctx.Org.Organization.ID, - Name: form.Name, - Description: form.Description, - IsAllRepositories: form.IsAllRepositories, - Authorize: models.ParseAccessMode(form.Permission), + OrgID: ctx.Org.Organization.ID, + Name: form.Name, + Description: form.Description, + IncludesAllRepositories: form.IncludesAllRepositories, + Authorize: models.ParseAccessMode(form.Permission), } unitTypes := models.FindUnitTypes(form.Units...) @@ -183,7 +183,7 @@ func EditTeam(ctx *context.APIContext, form api.EditTeamOption) { team := ctx.Org.Team team.Name = form.Name team.Description = form.Description - team.IsAllRepositories = form.IsAllRepositories + team.IncludesAllRepositories = form.IncludesAllRepositories team.Authorize = models.ParseAccessMode(form.Permission) unitTypes := models.FindUnitTypes(form.Units...) diff --git a/routers/org/teams.go b/routers/org/teams.go index dc52fb5b0e..26f5c62471 100644 --- a/routers/org/teams.go +++ b/routers/org/teams.go @@ -182,11 +182,11 @@ func NewTeamPost(ctx *context.Context, form auth.CreateTeamForm) { ctx.Data["Units"] = models.Units t := &models.Team{ - OrgID: ctx.Org.Organization.ID, - Name: form.TeamName, - Description: form.Description, - Authorize: models.ParseAccessMode(form.Permission), - IsAllRepositories: form.IsAllRepositories, + OrgID: ctx.Org.Organization.ID, + Name: form.TeamName, + Description: form.Description, + Authorize: models.ParseAccessMode(form.Permission), + IncludesAllRepositories: form.IncludesAllRepositories, } if t.Authorize < models.AccessModeOwner { @@ -279,7 +279,7 @@ func EditTeamPost(ctx *context.Context, form auth.CreateTeamForm) { t.Authorize = auth } - t.IsAllRepositories = form.IsAllRepositories + t.IncludesAllRepositories = form.IncludesAllRepositories } t.Description = form.Description if t.Authorize < models.AccessModeOwner { diff --git a/templates/org/team/new.tmpl b/templates/org/team/new.tmpl index c32b482224..270df5edec 100644 --- a/templates/org/team/new.tmpl +++ b/templates/org/team/new.tmpl @@ -26,8 +26,8 @@ {{if not (eq .Team.LowerName "owners")}}
- - + + {{.i18n.Tr "org.teams.all_repositories_helper"}}
diff --git a/templates/org/team/repositories.tmpl b/templates/org/team/repositories.tmpl index 49f08bb724..1b2a411c2b 100644 --- a/templates/org/team/repositories.tmpl +++ b/templates/org/team/repositories.tmpl @@ -7,7 +7,7 @@ {{template "org/team/sidebar" .}}
{{template "org/team/navbar" .}} - {{$canAddRemove := and $.IsOrganizationOwner (not $.Team.IsAllRepositories)}} + {{$canAddRemove := and $.IsOrganizationOwner (not $.Team.IncludesAllRepositories)}} {{if $canAddRemove}}
diff --git a/templates/org/team/sidebar.tmpl b/templates/org/team/sidebar.tmpl index 840089daf0..dd189df5f3 100644 --- a/templates/org/team/sidebar.tmpl +++ b/templates/org/team/sidebar.tmpl @@ -22,19 +22,19 @@ {{if eq .Team.LowerName "owners"}} {{.i18n.Tr "org.teams.owners_permission_desc" | Str2html}} {{else if (eq .Team.Authorize 1)}} - {{if .Team.IsAllRepositories}} + {{if .Team.IncludesAllRepositories}} {{.i18n.Tr "org.teams.all_repositories_read_permission_desc" | Str2html}} {{else}} {{.i18n.Tr "org.teams.read_permission_desc" | Str2html}} {{end}} {{else if (eq .Team.Authorize 2)}} - {{if .Team.IsAllRepositories}} + {{if .Team.IncludesAllRepositories}} {{.i18n.Tr "org.teams.all_repositories_write_permission_desc" | Str2html}} {{else}} {{.i18n.Tr "org.teams.write_permission_desc" | Str2html}} {{end}} {{else if (eq .Team.Authorize 3)}} - {{if .Team.IsAllRepositories}} + {{if .Team.IncludesAllRepositories}} {{.i18n.Tr "org.teams.all_repositories_admin_permission_desc" | Str2html}} {{else}} {{.i18n.Tr "org.teams.admin_permission_desc" | Str2html}} diff --git a/templates/swagger/v1_json.tmpl b/templates/swagger/v1_json.tmpl index e7438f7280..85e3cced69 100644 --- a/templates/swagger/v1_json.tmpl +++ b/templates/swagger/v1_json.tmpl @@ -7298,9 +7298,9 @@ "type": "string", "x-go-name": "Description" }, - "is_all_repositories": { + "includes_all_repositories": { "type": "boolean", - "x-go-name": "IsAllRepositories" + "x-go-name": "IncludesAllRepositories" }, "name": { "type": "string", @@ -7737,9 +7737,9 @@ "type": "string", "x-go-name": "Description" }, - "is_all_repositories": { + "includes_all_repositories": { "type": "boolean", - "x-go-name": "IsAllRepositories" + "x-go-name": "IncludesAllRepositories" }, "name": { "type": "string", @@ -9260,9 +9260,9 @@ "format": "int64", "x-go-name": "ID" }, - "is_all_repositories": { + "includes_all_repositories": { "type": "boolean", - "x-go-name": "IsAllRepositories" + "x-go-name": "IncludesAllRepositories" }, "name": { "type": "string", diff --git a/vendor/code.gitea.io/sdk/gitea/org_team.go b/vendor/code.gitea.io/sdk/gitea/org_team.go index f82401cd47..35bac17f5c 100644 --- a/vendor/code.gitea.io/sdk/gitea/org_team.go +++ b/vendor/code.gitea.io/sdk/gitea/org_team.go @@ -7,11 +7,11 @@ package gitea // Team represents a team in an organization type Team struct { - ID int64 `json:"id"` - Name string `json:"name"` - Description string `json:"description"` - Organization *Organization `json:"organization"` - IsAllRepositories bool `json:"is_all_repositories"` + ID int64 `json:"id"` + Name string `json:"name"` + Description string `json:"description"` + Organization *Organization `json:"organization"` + IncludesAllRepositories bool `json:"includes_all_repositories"` // enum: none,read,write,admin,owner Permission string `json:"permission"` // enum: repo.code,repo.issues,repo.ext_issues,repo.wiki,repo.pulls,repo.releases,repo.ext_wiki @@ -21,9 +21,9 @@ type Team struct { // CreateTeamOption options for creating a team type CreateTeamOption struct { // required: true - Name string `json:"name" binding:"Required;AlphaDashDot;MaxSize(30)"` - Description string `json:"description" binding:"MaxSize(255)"` - IsAllRepositories bool `json:"is_all_repositories"` + Name string `json:"name" binding:"Required;AlphaDashDot;MaxSize(30)"` + Description string `json:"description" binding:"MaxSize(255)"` + IncludesAllRepositories bool `json:"includes_all_repositories"` // enum: read,write,admin Permission string `json:"permission"` // enum: repo.code,repo.issues,repo.ext_issues,repo.wiki,repo.pulls,repo.releases,repo.ext_wiki @@ -33,9 +33,9 @@ type CreateTeamOption struct { // EditTeamOption options for editing a team type EditTeamOption struct { // required: true - Name string `json:"name" binding:"Required;AlphaDashDot;MaxSize(30)"` - Description string `json:"description" binding:"MaxSize(255)"` - IsAllRepositories bool `json:"is_all_repositories"` + Name string `json:"name" binding:"Required;AlphaDashDot;MaxSize(30)"` + Description string `json:"description" binding:"MaxSize(255)"` + IncludesAllRepositories bool `json:"includes_all_repositories"` // enum: read,write,admin Permission string `json:"permission"` // enum: repo.code,repo.issues,repo.ext_issues,repo.wiki,repo.pulls,repo.releases,repo.ext_wiki