diff options
author | Unknown <joe2010xtmf@163.com> | 2014-03-17 04:33:59 -0400 |
---|---|---|
committer | Unknown <joe2010xtmf@163.com> | 2014-03-17 04:33:59 -0400 |
commit | 5c3054c3b7387df56db8c193db7c662802fb4a50 (patch) | |
tree | 35721683878c4f6ae36cddf444bd55b099434f1e /routers | |
parent | cf9fa06eae68cea08c3f2fb28644a80bb08be2c3 (diff) | |
parent | 24d91ecda8c819a33f326ff724559456bcae6d71 (diff) | |
download | gitea-5c3054c3b7387df56db8c193db7c662802fb4a50.tar.gz gitea-5c3054c3b7387df56db8c193db7c662802fb4a50.zip |
Merge branch 'master' of github.com:gogits/gogs
Diffstat (limited to 'routers')
-rw-r--r-- | routers/repo/repo.go | 54 | ||||
-rw-r--r-- | routers/repo/single.go | 3 |
2 files changed, 22 insertions, 35 deletions
diff --git a/routers/repo/repo.go b/routers/repo/repo.go index 116c199b7d..edd8862794 100644 --- a/routers/repo/repo.go +++ b/routers/repo/repo.go @@ -20,49 +20,35 @@ func Create(ctx *middleware.Context, form auth.CreateRepoForm) { return } - if ctx.HasError() { - ctx.Render.HTML(200, "repo/create", ctx.Data) + if _, err := models.CreateRepository(ctx.User, + form.RepoName, form.Description, form.Language, form.License, + form.Visibility == "private", form.InitReadme == "on"); err == nil { + ctx.Render.Redirect("/"+ctx.User.Name+"/"+form.RepoName, 302) return - } - - // TODO: access check - - user, err := models.GetUserById(form.UserId) - if err != nil { - if err.Error() == models.ErrUserNotExist.Error() { - ctx.RenderWithErr("User does not exist", "repo/create", &form) - return - } - } - - if err == nil { - if _, err = models.CreateRepository(user, - form.RepoName, form.Description, form.Language, form.License, - form.Visibility == "private", form.InitReadme == "on"); err == nil { - ctx.Render.Redirect("/"+user.Name+"/"+form.RepoName, 302) - return - } - } - - if err.Error() == models.ErrRepoAlreadyExist.Error() { + } else if err == models.ErrRepoAlreadyExist { ctx.RenderWithErr("Repository name has already been used", "repo/create", &form) return } - - ctx.Handle(200, "repo.Create", err) } -func Delete(ctx *middleware.Context, form auth.DeleteRepoForm) { - ctx.Data["Title"] = "Delete repository" - - if ctx.Req.Method == "GET" { - ctx.Render.HTML(200, "repo/delete", ctx.Data) +func SettingPost(ctx *middleware.Context) { + if !ctx.Repo.IsOwner { + ctx.Render.Error(404) return } - if err := models.DeleteRepository(form.UserId, form.RepoId, form.UserName); err != nil { - ctx.Handle(200, "repo.Delete", err) - return + switch ctx.Query("action") { + case "delete": + if len(ctx.Repo.Repository.Name) == 0 || ctx.Repo.Repository.Name != ctx.Query("repository") { + ctx.Data["ErrorMsg"] = "Please make sure you entered repository name is correct." + ctx.Render.HTML(200, "repo/setting", ctx.Data) + return + } + + if err := models.DeleteRepository(ctx.User.Id, ctx.Repo.Repository.Id, ctx.User.LowerName); err != nil { + ctx.Handle(200, "repo.Delete", err) + return + } } ctx.Render.Redirect("/", 302) diff --git a/routers/repo/single.go b/routers/repo/single.go index 75eb112503..d1ad36d45b 100644 --- a/routers/repo/single.go +++ b/routers/repo/single.go @@ -78,7 +78,8 @@ func Single(ctx *middleware.Context, params martini.Params) { } func Setting(ctx *middleware.Context, params martini.Params) { - if !ctx.Repo.IsValid { + if !ctx.Repo.IsOwner { + ctx.Render.Error(404) return } |