1
0
Fork 0
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:
Nicolas Gourdon 2019-04-30 20:43:38 +02:00
parent a02aa18985
commit 8216a2a210
16 changed files with 111 additions and 111 deletions

View file

@ -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)
}

View file

@ -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

View file

@ -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
}

View file

@ -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)

View file

@ -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)

View file

@ -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)

View file

@ -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)
}

View file

@ -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

View file

@ -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(),
}
}

View file

@ -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...)

View file

@ -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 {

View file

@ -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>

View file

@ -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">

View file

@ -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}}

View file

@ -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",

View file

@ -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