mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-01-09 15:28:22 -05:00
rename IsAllRepositories to IncludesAllRepositories
This commit is contained in:
parent
a02aa18985
commit
8216a2a210
16 changed files with 111 additions and 111 deletions
|
@ -57,16 +57,16 @@ func TestAPITeam(t *testing.T) {
|
|||
teamToCreate := &api.CreateTeamOption{
|
||||
Name: "team1",
|
||||
Description: "team one",
|
||||
IsAllRepositories: true,
|
||||
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
|
||||
|
||||
|
@ -74,16 +74,16 @@ func TestAPITeam(t *testing.T) {
|
|||
teamToEdit := &api.EditTeamOption{
|
||||
Name: "teamone",
|
||||
Description: "team 1",
|
||||
IsAllRepositories: false,
|
||||
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)
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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"`
|
||||
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
|
||||
}
|
||||
|
|
|
@ -157,7 +157,7 @@ func CreateOrganization(org, owner *User) (err error) {
|
|||
Name: ownerTeamName,
|
||||
Authorize: AccessModeOwner,
|
||||
NumMembers: 1,
|
||||
IsAllRepositories: true,
|
||||
IncludesAllRepositories: true,
|
||||
}
|
||||
if _, err = sess.Insert(t); err != nil {
|
||||
return fmt.Errorf("insert owner team: %v", err)
|
||||
|
|
|
@ -32,7 +32,7 @@ type Team struct {
|
|||
NumRepos int
|
||||
NumMembers int
|
||||
Units []*TeamUnit `xorm:"-"`
|
||||
IsAllRepositories bool `xorm:"NOT NULL DEFAULT false"`
|
||||
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)
|
||||
|
|
|
@ -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)
|
||||
|
@ -416,25 +416,25 @@ func TestAllRepositoriesTeams(t *testing.T) {
|
|||
OrgID: org.ID,
|
||||
Name: "team one",
|
||||
Authorize: AccessModeRead,
|
||||
IsAllRepositories: true,
|
||||
IncludesAllRepositories: true,
|
||||
},
|
||||
{
|
||||
OrgID: org.ID,
|
||||
Name: "team 2",
|
||||
Authorize: AccessModeRead,
|
||||
IsAllRepositories: false,
|
||||
IncludesAllRepositories: false,
|
||||
},
|
||||
{
|
||||
OrgID: org.ID,
|
||||
Name: "team three",
|
||||
Authorize: AccessModeWrite,
|
||||
IsAllRepositories: true,
|
||||
IncludesAllRepositories: true,
|
||||
},
|
||||
{
|
||||
OrgID: org.ID,
|
||||
Name: "team 4",
|
||||
Authorize: AccessModeWrite,
|
||||
IsAllRepositories: false,
|
||||
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)
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ type CreateTeamForm struct {
|
|||
Description string `binding:"MaxSize(255)"`
|
||||
Permission string
|
||||
Units []models.UnitType
|
||||
IsAllRepositories bool
|
||||
IncludesAllRepositories bool
|
||||
}
|
||||
|
||||
// Validate validates the fields
|
||||
|
|
|
@ -222,7 +222,7 @@ func ToTeam(team *models.Team) *api.Team {
|
|||
ID: team.ID,
|
||||
Name: team.Name,
|
||||
Description: team.Description,
|
||||
IsAllRepositories: team.IsAllRepositories,
|
||||
IncludesAllRepositories: team.IncludesAllRepositories,
|
||||
Permission: team.Authorize.String(),
|
||||
Units: team.GetUnitNames(),
|
||||
}
|
||||
|
|
|
@ -129,7 +129,7 @@ func CreateTeam(ctx *context.APIContext, form api.CreateTeamOption) {
|
|||
OrgID: ctx.Org.Organization.ID,
|
||||
Name: form.Name,
|
||||
Description: form.Description,
|
||||
IsAllRepositories: form.IsAllRepositories,
|
||||
IncludesAllRepositories: form.IncludesAllRepositories,
|
||||
Authorize: models.ParseAccessMode(form.Permission),
|
||||
}
|
||||
|
||||
|
@ -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...)
|
||||
|
||||
|
|
|
@ -186,7 +186,7 @@ func NewTeamPost(ctx *context.Context, form auth.CreateTeamForm) {
|
|||
Name: form.TeamName,
|
||||
Description: form.Description,
|
||||
Authorize: models.ParseAccessMode(form.Permission),
|
||||
IsAllRepositories: form.IsAllRepositories,
|
||||
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 {
|
||||
|
|
|
@ -26,8 +26,8 @@
|
|||
{{if not (eq .Team.LowerName "owners")}}
|
||||
<div class="inline field">
|
||||
<div class="ui checkbox">
|
||||
<label for="is_all_repositories">{{.i18n.Tr "org.teams.all_repositories"}}</label>
|
||||
<input id="is_all_repositories" name="is_all_repositories" type="checkbox" {{if .Team.IsAllRepositories}}checked{{end}}>
|
||||
<label for="includes_all_repositories">{{.i18n.Tr "org.teams.all_repositories"}}</label>
|
||||
<input id="includes_all_repositories" name="includes_all_repositories" type="checkbox" {{if .Team.IncludesAllRepositories}}checked{{end}}>
|
||||
<span class="help">{{.i18n.Tr "org.teams.all_repositories_helper"}}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
{{template "org/team/sidebar" .}}
|
||||
<div class="ui ten wide column">
|
||||
{{template "org/team/navbar" .}}
|
||||
{{$canAddRemove := and $.IsOrganizationOwner (not $.Team.IsAllRepositories)}}
|
||||
{{$canAddRemove := and $.IsOrganizationOwner (not $.Team.IncludesAllRepositories)}}
|
||||
{{if $canAddRemove}}
|
||||
<div class="ui attached segment">
|
||||
<form class="ui form" id="add-repo-form" action="{{$.OrgLink}}/teams/{{$.Team.LowerName}}/action/repo/add" method="post">
|
||||
|
|
|
@ -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}}
|
||||
|
|
|
@ -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",
|
||||
|
|
6
vendor/code.gitea.io/sdk/gitea/org_team.go
generated
vendored
6
vendor/code.gitea.io/sdk/gitea/org_team.go
generated
vendored
|
@ -11,7 +11,7 @@ type Team struct {
|
|||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
Organization *Organization `json:"organization"`
|
||||
IsAllRepositories bool `json:"is_all_repositories"`
|
||||
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
|
||||
|
@ -23,7 +23,7 @@ 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"`
|
||||
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
|
||||
|
@ -35,7 +35,7 @@ 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"`
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue