diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2014-03-29 14:35:54 +0800 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2014-03-29 14:35:54 +0800 |
commit | f48fc24670b122df069149801459eb55a67045c7 (patch) | |
tree | 04a054e989341953072f854134a50d62f75993c8 /routers/repo/issue.go | |
parent | e085d7738a683785a5d7d7e3a33a0437c87c340b (diff) | |
parent | d01820c125669367b7a585d767d5f11e73a701c2 (diff) |
Merge branch 'master' of github.com:gogits/gogs
Diffstat (limited to 'routers/repo/issue.go')
-rw-r--r-- | routers/repo/issue.go | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/routers/repo/issue.go b/routers/repo/issue.go index 77e35bba..6ac8a535 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -40,9 +40,7 @@ func Issues(ctx *middleware.Context) { ctx.Redirect("/user/login/", 302) return } - posterId = ctx.User.Id ctx.Data["ViewType"] = "created_by" - ctx.Data["IssueCreatedCount"] = models.GetUserIssueCount(posterId, ctx.Repo.Repository.Id) } // Get issues. @@ -53,6 +51,11 @@ func Issues(ctx *middleware.Context) { return } + if ctx.IsSigned { + posterId = ctx.User.Id + } + var createdByCount int + // Get posters. for i := range issues { u, err := models.GetUserById(issues[i].PosterId) @@ -61,12 +64,16 @@ func Issues(ctx *middleware.Context) { return } issues[i].Poster = u + if u.Id == posterId { + createdByCount++ + } } ctx.Data["Issues"] = issues ctx.Data["IssueCount"] = ctx.Repo.Repository.NumIssues ctx.Data["OpenCount"] = ctx.Repo.Repository.NumIssues - ctx.Repo.Repository.NumClosedIssues ctx.Data["ClosedCount"] = ctx.Repo.Repository.NumClosedIssues + ctx.Data["IssueCreatedCount"] = createdByCount ctx.Data["IsShowClosed"] = ctx.Query("state") == "closed" ctx.HTML(200, "issue/list") } @@ -224,6 +231,12 @@ func Comment(ctx *middleware.Context, params martini.Params) { return } + content := ctx.Query("content") + if len(content) == 0 { + ctx.Redirect(fmt.Sprintf("/%s/%s/issues/%d", ctx.User.Name, ctx.Repo.Repository.Name, index)) + return + } + issue, err := models.GetIssueByIndex(ctx.Repo.Repository.Id, int64(index)) if err != nil { if err == models.ErrIssueNotExist { @@ -234,12 +247,6 @@ func Comment(ctx *middleware.Context, params martini.Params) { return } - content := ctx.Query("content") - if len(content) == 0 { - ctx.Handle(404, "issue.Comment", err) - return - } - switch params["action"] { case "new": if err = models.CreateComment(ctx.User.Id, issue.Id, 0, 0, content); err != nil { |