summaryrefslogtreecommitdiffstats
path: root/routers/api/v1
diff options
context:
space:
mode:
Diffstat (limited to 'routers/api/v1')
-rw-r--r--routers/api/v1/convert/convert.go11
-rw-r--r--routers/api/v1/org/team.go31
2 files changed, 30 insertions, 12 deletions
diff --git a/routers/api/v1/convert/convert.go b/routers/api/v1/convert/convert.go
index 6da53d6275..f52ed63476 100644
--- a/routers/api/v1/convert/convert.go
+++ b/routers/api/v1/convert/convert.go
@@ -227,11 +227,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,
- 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 d01f051626..a22b60a2c6 100644
--- a/routers/api/v1/org/team.go
+++ b/routers/api/v1/org/team.go
@@ -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
}