diff options
author | Unknown <joe2010xtmf@163.com> | 2014-05-24 03:05:41 -0400 |
---|---|---|
committer | Unknown <joe2010xtmf@163.com> | 2014-05-24 03:05:41 -0400 |
commit | dce17c86ac26f2110e6067e8f85340122fe5d1e0 (patch) | |
tree | 76311a047138f0a71f1ede9b16035500e9092a8e /routers/repo/issue.go | |
parent | b1bdbd7f948b0598e69355ba8312a50c74bc04a7 (diff) | |
download | gitea-dce17c86ac26f2110e6067e8f85340122fe5d1e0.tar.gz gitea-dce17c86ac26f2110e6067e8f85340122fe5d1e0.zip |
Almost done issue label #200
Diffstat (limited to 'routers/repo/issue.go')
-rw-r--r-- | routers/repo/issue.go | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/routers/repo/issue.go b/routers/repo/issue.go index 0c0b7348f4..23f2480dda 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -445,7 +445,7 @@ func UpdateIssueLabel(ctx *middleware.Context, params martini.Params) { issue, err := models.GetIssueByIndex(ctx.Repo.Repository.Id, idx) if err != nil { if err == models.ErrIssueNotExist { - ctx.Handle(404, "issue.UpdateIssueLabel", err) + ctx.Handle(404, "issue.UpdateIssueLabel(GetIssueByIndex)", err) } else { ctx.Handle(500, "issue.UpdateIssueLabel(GetIssueByIndex)", err) } @@ -454,6 +454,17 @@ func UpdateIssueLabel(ctx *middleware.Context, params martini.Params) { isAttach := ctx.Query("action") == "attach" labelStrId := ctx.Query("id") + labelId, _ := base.StrTo(labelStrId).Int64() + label, err := models.GetLabelById(labelId) + if err != nil { + if err == models.ErrLabelNotExist { + ctx.Handle(404, "issue.UpdateIssueLabel(GetLabelById)", err) + } else { + ctx.Handle(500, "issue.UpdateIssueLabel(GetLabelById)", err) + } + return + } + isHad := strings.Contains(issue.LabelIds, "$"+labelStrId+"|") isNeedUpdate := false if isAttach { @@ -473,6 +484,22 @@ func UpdateIssueLabel(ctx *middleware.Context, params martini.Params) { ctx.Handle(500, "issue.UpdateIssueLabel(UpdateIssue)", err) return } + + if isAttach { + label.NumIssues++ + if issue.IsClosed { + label.NumClosedIssues++ + } + } else { + label.NumIssues-- + if issue.IsClosed { + label.NumClosedIssues-- + } + } + if err = models.UpdateLabel(label); err != nil { + ctx.Handle(500, "issue.UpdateIssueLabel(UpdateLabel)", err) + return + } } ctx.JSON(200, map[string]interface{}{ "ok": true, |