mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-15 14:32:42 +00:00
Add team option to grant rights for all organization repositories (#8688)
* Add field IsAllRepositories to team
* Add AllRepositories to team UI
* Manage team with access to all repositories
* Add field IsAllRepositories to team API
* put backticks around table/column names
* rename IsAllRepositories to IncludesAllRepositories
* do not reload slice if already loaded
* add repo to teams with access to all repositories when changing repo owner
* improve tests for teams with access to all repositories
* Merge branch 'master'
* Change code for adding all repositories
Signed-off-by: David Svantesson <davidsvantesson@gmail.com>
* fmt after merge
* Change code in API EditTeam similar to EditTeamPost web interface
Signed-off-by: David Svantesson <davidsvantesson@gmail.com>
* Clarify that all repositories will be added
Signed-off-by: David Svantesson <davidsvantesson@gmail.com>
* All repositories option under Permissions headline
* New setting group 'Repository access'
* Move check IncludeAllRepositories to removeRepository.
* Revert "Move check IncludeAllRepositories to removeRepository." and add comment instead.
This reverts commit 753b7d205b
.
* Clarify help text what options do.
This commit is contained in:
parent
0109229928
commit
72aa5a20ec
17 changed files with 382 additions and 75 deletions
|
@ -128,10 +128,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,
|
||||
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...)
|
||||
|
@ -182,11 +183,27 @@ func EditTeam(ctx *context.APIContext, form api.EditTeamOption) {
|
|||
// "200":
|
||||
// "$ref": "#/responses/Team"
|
||||
team := ctx.Org.Team
|
||||
team.Name = form.Name
|
||||
team.Description = form.Description
|
||||
team.Authorize = models.ParseAccessMode(form.Permission)
|
||||
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 {
|
||||
var units = make([]*models.TeamUnit, 0, len(form.Units))
|
||||
for _, tp := range unitTypes {
|
||||
|
@ -198,7 +215,7 @@ func EditTeam(ctx *context.APIContext, form api.EditTeamOption) {
|
|||
team.Units = units
|
||||
}
|
||||
|
||||
if err := models.UpdateTeam(team, true); err != nil {
|
||||
if err := models.UpdateTeam(team, isAuthChanged, isIncludeAllChanged); err != nil {
|
||||
ctx.Error(500, "EditTeam", err)
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue