diff options
author | Unknown <joe2010xtmf@163.com> | 2014-06-25 05:14:36 -0400 |
---|---|---|
committer | Unknown <joe2010xtmf@163.com> | 2014-06-25 05:14:36 -0400 |
commit | 43b33440b53c79a22de08880851b5b55e9b6a4b3 (patch) | |
tree | 4ae44f5d94aa99149035c04e518a91090fe4932a /routers/repo/repo.go | |
parent | 72ba273cc99589d7a0ca0a7986939e86f6599bf8 (diff) | |
download | gitea-43b33440b53c79a22de08880851b5b55e9b6a4b3.tar.gz gitea-43b33440b53c79a22de08880851b5b55e9b6a4b3.zip |
Work on create organization repo and #257
Diffstat (limited to 'routers/repo/repo.go')
-rw-r--r-- | routers/repo/repo.go | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/routers/repo/repo.go b/routers/repo/repo.go index 6d24169926..d96456422b 100644 --- a/routers/repo/repo.go +++ b/routers/repo/repo.go @@ -63,11 +63,26 @@ func CreatePost(ctx *middleware.Context, form auth.CreateRepoForm) { return } - repo, err := models.CreateRepository(ctx.User, form.RepoName, form.Description, + u := ctx.User + // Not equal means current user is an organization. + if u.Id != form.Uid { + var err error + u, err = models.GetUserById(form.Uid) + if err != nil { + if err == models.ErrUserNotExist { + ctx.Handle(404, "home.Dashboard(GetUserById)", err) + } else { + ctx.Handle(500, "home.Dashboard(GetUserById)", err) + } + return + } + } + + repo, err := models.CreateRepository(u, form.RepoName, form.Description, form.Language, form.License, form.Private, false, form.InitReadme) if err == nil { - log.Trace("%s Repository created: %s/%s", ctx.Req.RequestURI, ctx.User.LowerName, form.RepoName) - ctx.Redirect("/" + ctx.User.Name + "/" + form.RepoName) + log.Trace("%s Repository created: %s/%s", ctx.Req.RequestURI, u.LowerName, form.RepoName) + ctx.Redirect("/" + u.Name + "/" + form.RepoName) return } else if err == models.ErrRepoAlreadyExist { ctx.RenderWithErr("Repository name has already been used", CREATE, &form) @@ -78,7 +93,7 @@ func CreatePost(ctx *middleware.Context, form auth.CreateRepoForm) { } if repo != nil { - if errDelete := models.DeleteRepository(ctx.User.Id, repo.Id, ctx.User.Name); errDelete != nil { + if errDelete := models.DeleteRepository(u.Id, repo.Id, u.Name); errDelete != nil { log.Error("repo.CreatePost(DeleteRepository): %v", errDelete) } } |