aboutsummaryrefslogtreecommitdiffstats
path: root/routers/repo/issue.go
diff options
context:
space:
mode:
authorUnknown <joe2010xtmf@163.com>2014-03-26 12:31:01 -0400
committerUnknown <joe2010xtmf@163.com>2014-03-26 12:31:01 -0400
commit4b9eef50c9bf91e6ca2d85d9e63dc69b0ffba737 (patch)
tree15c5fd6dd9b72ba61e306ec8b068b35d3bc19239 /routers/repo/issue.go
parent8c2f751bbb22ebf06c7f7f9621614b6e46130210 (diff)
downloadgitea-4b9eef50c9bf91e6ca2d85d9e63dc69b0ffba737.tar.gz
gitea-4b9eef50c9bf91e6ca2d85d9e63dc69b0ffba737.zip
Add comment of issue
Diffstat (limited to 'routers/repo/issue.go')
-rw-r--r--routers/repo/issue.go68
1 files changed, 66 insertions, 2 deletions
diff --git a/routers/repo/issue.go b/routers/repo/issue.go
index 72d07d4acf..e53aebf636 100644
--- a/routers/repo/issue.go
+++ b/routers/repo/issue.go
@@ -113,8 +113,34 @@ func ViewIssue(ctx *middleware.Context, params martini.Params) {
return
}
+ // Get posters.
+ u, err := models.GetUserById(issue.PosterId)
+ if err != nil {
+ ctx.Handle(200, "issue.ViewIssue(get poster): %v", err)
+ return
+ }
+ issue.Poster = u
+
+ // Get comments.
+ comments, err := models.GetIssueComments(issue.Id)
+ if err != nil {
+ ctx.Handle(200, "issue.ViewIssue(get comments): %v", err)
+ return
+ }
+
+ // Get posters.
+ for i := range comments {
+ u, err := models.GetUserById(comments[i].PosterId)
+ if err != nil {
+ ctx.Handle(200, "issue.ViewIssue(get poster): %v", err)
+ return
+ }
+ comments[i].Poster = u
+ }
+
ctx.Data["Title"] = issue.Name
ctx.Data["Issue"] = issue
+ ctx.Data["Comments"] = comments
ctx.Data["IsRepoToolbarIssues"] = true
ctx.Data["IsRepoToolbarIssuesList"] = false
ctx.HTML(200, "issue/view")
@@ -132,7 +158,7 @@ func UpdateIssue(ctx *middleware.Context, params martini.Params, form auth.Creat
if err == models.ErrIssueNotExist {
ctx.Handle(404, "issue.UpdateIssue", err)
} else {
- ctx.Handle(200, "issue.UpdateIssue", err)
+ ctx.Handle(200, "issue.UpdateIssue(get issue)", err)
}
return
}
@@ -148,10 +174,48 @@ func UpdateIssue(ctx *middleware.Context, params martini.Params, form auth.Creat
issue.Labels = form.Labels
issue.Content = form.Content
if err = models.UpdateIssue(issue); err != nil {
- ctx.Handle(200, "issue.UpdateIssue", err)
+ ctx.Handle(200, "issue.UpdateIssue(update issue)", err)
return
}
ctx.Data["Title"] = issue.Name
ctx.Data["Issue"] = issue
}
+
+func Comment(ctx *middleware.Context, params martini.Params) {
+ index, err := base.StrTo(ctx.Query("issueIndex")).Int()
+ if err != nil {
+ ctx.Handle(404, "issue.Comment", err)
+ return
+ }
+
+ issue, err := models.GetIssueByIndex(ctx.Repo.Repository.Id, int64(index))
+ if err != nil {
+ if err == models.ErrIssueNotExist {
+ ctx.Handle(404, "issue.Comment", err)
+ } else {
+ ctx.Handle(200, "issue.Comment(get issue)", err)
+ }
+ 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 {
+ ctx.Handle(500, "issue.Comment(create comment)", err)
+ return
+ }
+ log.Trace("%s Comment created: %d", ctx.Req.RequestURI, issue.Id)
+ default:
+ ctx.Handle(404, "issue.Comment", err)
+ return
+ }
+
+ ctx.Redirect(fmt.Sprintf("/%s/%s/issues/%d", ctx.User.Name, ctx.Repo.Repository.Name, index))
+}