Team permission to create repository in organization (#8312)
* Add team permission setting to allow creating repo in organization. Signed-off-by: David Svantesson <davidsvantesson@gmail.com> * Add test case for creating repo when have team creation access. Signed-off-by: David Svantesson <davidsvantesson@gmail.com> * build error: should omit comparison to bool constant Signed-off-by: David Svantesson <davidsvantesson@gmail.com> * Add comment on exported functions * Fix fixture consistency, fix existing unit tests * Fix boolean comparison in xorm query. * addCollaborator and changeCollaborationAccessMode separate steps More clear to use different if-cases. * Create and commit xorm session * fix * Add information of create repo permission in team sidebar * Add migration step * Clarify that repository creator will be administrator. * Fix some things after merge * Fix language text that use html * migrations file * Create repository permission -> Create repositories * fix merge * fix review comments
This commit is contained in:
parent
35c3ea952a
commit
69a255defb
27 changed files with 252 additions and 63 deletions
|
@ -58,11 +58,12 @@ 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
|
||||
RepoAccess string
|
||||
TeamName string `binding:"Required;AlphaDashDot;MaxSize(30)"`
|
||||
Description string `binding:"MaxSize(255)"`
|
||||
Permission string
|
||||
Units []models.UnitType
|
||||
RepoAccess string
|
||||
CanCreateOrgRepo bool
|
||||
}
|
||||
|
||||
// Validate validates the fields
|
||||
|
|
|
@ -15,12 +15,13 @@ import (
|
|||
|
||||
// Organization contains organization context
|
||||
type Organization struct {
|
||||
IsOwner bool
|
||||
IsMember bool
|
||||
IsTeamMember bool // Is member of team.
|
||||
IsTeamAdmin bool // In owner team or team that has admin permission level.
|
||||
Organization *models.User
|
||||
OrgLink string
|
||||
IsOwner bool
|
||||
IsMember bool
|
||||
IsTeamMember bool // Is member of team.
|
||||
IsTeamAdmin bool // In owner team or team that has admin permission level.
|
||||
Organization *models.User
|
||||
OrgLink string
|
||||
CanCreateOrgRepo bool
|
||||
|
||||
Team *models.Team
|
||||
}
|
||||
|
@ -73,6 +74,7 @@ func HandleOrgAssignment(ctx *Context, args ...bool) {
|
|||
ctx.Org.IsMember = true
|
||||
ctx.Org.IsTeamMember = true
|
||||
ctx.Org.IsTeamAdmin = true
|
||||
ctx.Org.CanCreateOrgRepo = true
|
||||
} else if ctx.IsSigned {
|
||||
ctx.Org.IsOwner, err = org.IsOwnedBy(ctx.User.ID)
|
||||
if err != nil {
|
||||
|
@ -84,12 +86,18 @@ func HandleOrgAssignment(ctx *Context, args ...bool) {
|
|||
ctx.Org.IsMember = true
|
||||
ctx.Org.IsTeamMember = true
|
||||
ctx.Org.IsTeamAdmin = true
|
||||
ctx.Org.CanCreateOrgRepo = true
|
||||
} else {
|
||||
ctx.Org.IsMember, err = org.IsOrgMember(ctx.User.ID)
|
||||
if err != nil {
|
||||
ctx.ServerError("IsOrgMember", err)
|
||||
return
|
||||
}
|
||||
ctx.Org.CanCreateOrgRepo, err = org.CanCreateOrgRepo(ctx.User.ID)
|
||||
if err != nil {
|
||||
ctx.ServerError("CanCreateOrgRepo", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Fake data.
|
||||
|
@ -102,6 +110,7 @@ func HandleOrgAssignment(ctx *Context, args ...bool) {
|
|||
}
|
||||
ctx.Data["IsOrganizationOwner"] = ctx.Org.IsOwner
|
||||
ctx.Data["IsOrganizationMember"] = ctx.Org.IsMember
|
||||
ctx.Data["CanCreateOrgRepo"] = ctx.Org.CanCreateOrgRepo
|
||||
|
||||
ctx.Org.OrgLink = setting.AppSubURL + "/org/" + org.Name
|
||||
ctx.Data["OrgLink"] = ctx.Org.OrgLink
|
||||
|
|
|
@ -249,6 +249,7 @@ func ToTeam(team *models.Team) *api.Team {
|
|||
Name: team.Name,
|
||||
Description: team.Description,
|
||||
IncludesAllRepositories: team.IncludesAllRepositories,
|
||||
CanCreateOrgRepo: team.CanCreateOrgRepo,
|
||||
Permission: team.Authorize.String(),
|
||||
Units: team.GetUnitNames(),
|
||||
}
|
||||
|
|
|
@ -15,7 +15,8 @@ type Team struct {
|
|||
// enum: none,read,write,admin,owner
|
||||
Permission string `json:"permission"`
|
||||
// example: ["repo.code","repo.issues","repo.ext_issues","repo.wiki","repo.pulls","repo.releases","repo.ext_wiki"]
|
||||
Units []string `json:"units"`
|
||||
Units []string `json:"units"`
|
||||
CanCreateOrgRepo bool `json:"can_create_org_repo"`
|
||||
}
|
||||
|
||||
// CreateTeamOption options for creating a team
|
||||
|
@ -27,7 +28,8 @@ type CreateTeamOption struct {
|
|||
// enum: read,write,admin
|
||||
Permission string `json:"permission"`
|
||||
// example: ["repo.code","repo.issues","repo.ext_issues","repo.wiki","repo.pulls","repo.releases","repo.ext_wiki"]
|
||||
Units []string `json:"units"`
|
||||
Units []string `json:"units"`
|
||||
CanCreateOrgRepo bool `json:"can_create_org_repo"`
|
||||
}
|
||||
|
||||
// EditTeamOption options for editing a team
|
||||
|
@ -39,5 +41,6 @@ type EditTeamOption struct {
|
|||
// enum: read,write,admin
|
||||
Permission string `json:"permission"`
|
||||
// example: ["repo.code","repo.issues","repo.ext_issues","repo.wiki","repo.pulls","repo.releases","repo.ext_wiki"]
|
||||
Units []string `json:"units"`
|
||||
Units []string `json:"units"`
|
||||
CanCreateOrgRepo bool `json:"can_create_org_repo"`
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue