mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
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:
committed by
Lunny Xiao
parent
35c3ea952a
commit
69a255defb
@@ -53,9 +53,9 @@ func MustBeAbleToUpload(ctx *context.Context) {
|
||||
}
|
||||
|
||||
func checkContextUser(ctx *context.Context, uid int64) *models.User {
|
||||
orgs, err := models.GetOwnedOrgsByUserIDDesc(ctx.User.ID, "updated_unix")
|
||||
orgs, err := models.GetOrgsCanCreateRepoByUserID(ctx.User.ID)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetOwnedOrgsByUserIDDesc", err)
|
||||
ctx.ServerError("GetOrgsCanCreateRepoByUserID", err)
|
||||
return nil
|
||||
}
|
||||
ctx.Data["Orgs"] = orgs
|
||||
@@ -81,11 +81,11 @@ func checkContextUser(ctx *context.Context, uid int64) *models.User {
|
||||
return nil
|
||||
}
|
||||
if !ctx.User.IsAdmin {
|
||||
isOwner, err := org.IsOwnedBy(ctx.User.ID)
|
||||
canCreate, err := org.CanCreateOrgRepo(ctx.User.ID)
|
||||
if err != nil {
|
||||
ctx.ServerError("IsOwnedBy", err)
|
||||
ctx.ServerError("CanCreateOrgRepo", err)
|
||||
return nil
|
||||
} else if !isOwner {
|
||||
} else if !canCreate {
|
||||
ctx.Error(403)
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user