diff options
author | Unknwon <joe2010xtmf@163.com> | 2014-08-24 21:09:05 +0800 |
---|---|---|
committer | Unknwon <joe2010xtmf@163.com> | 2014-08-24 21:09:05 +0800 |
commit | 21a1b8e5a35c61bff30145ac3194ea893a9c6b68 (patch) | |
tree | b218aedd0d64252d95725f12338a1ced1f155ba9 /routers/repo/setting.go | |
parent | e325c8499a102ba8a6a84236c02dd7951f46cec5 (diff) | |
download | gitea-21a1b8e5a35c61bff30145ac3194ea893a9c6b68.tar.gz gitea-21a1b8e5a35c61bff30145ac3194ea893a9c6b68.zip |
Finish new edit team page, add member to team
Diffstat (limited to 'routers/repo/setting.go')
-rw-r--r-- | routers/repo/setting.go | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/routers/repo/setting.go b/routers/repo/setting.go index 10a6f72db7..866c0cd936 100644 --- a/routers/repo/setting.go +++ b/routers/repo/setting.go @@ -56,7 +56,12 @@ func SettingsPost(ctx *middleware.Context, form auth.RepoSettingForm) { ctx.RenderWithErr(ctx.Tr("form.repo_name_been_taken"), SETTINGS_OPTIONS, nil) return } else if err = models.ChangeRepositoryName(ctx.Repo.Owner.Name, ctx.Repo.Repository.Name, newRepoName); err != nil { - ctx.Handle(500, "ChangeRepositoryName", err) + if err == models.ErrRepoNameIllegal { + ctx.Data["Err_RepoName"] = true + ctx.RenderWithErr(ctx.Tr("form.illegal_repo_name"), SETTINGS_OPTIONS, nil) + } else { + ctx.Handle(500, "ChangeRepositoryName", err) + } return } log.Trace("Repository name changed: %s/%s -> %s", ctx.Repo.Owner.Name, ctx.Repo.Repository.Name, newRepoName) @@ -185,9 +190,24 @@ func SettingsCollaboration(ctx *middleware.Context) { // Delete collaborator. remove := strings.ToLower(ctx.Query("remove")) if len(remove) > 0 && remove != ctx.Repo.Owner.LowerName { - if err := models.DeleteAccess(&models.Access{UserName: remove, RepoName: repoLink}); err != nil { - ctx.Handle(500, "DeleteAccess", err) - return + needDelete := true + if ctx.User.IsOrganization() { + // Check if user belongs to a team that has access to this repository. + auth, err := models.GetHighestAuthorize(ctx.Repo.Owner.Id, ctx.User.Id, 0, ctx.Repo.Repository.Id) + if err != nil { + ctx.Handle(500, "GetHighestAuthorize", err) + return + } + if auth > 0 { + needDelete = false + } + } + + if needDelete { + if err := models.DeleteAccess(&models.Access{UserName: remove, RepoName: repoLink}); err != nil { + ctx.Handle(500, "DeleteAccess", err) + return + } } ctx.Flash.Success(ctx.Tr("repo.settings.remove_collaborator_success")) ctx.Redirect(ctx.Repo.RepoLink + "/settings/collaboration") |