|
|
@ -445,7 +445,7 @@ func UpdateIssueLabel(ctx *middleware.Context, params martini.Params) { |
|
|
|
issue, err := models.GetIssueByIndex(ctx.Repo.Repository.Id, idx) |
|
|
|
issue, err := models.GetIssueByIndex(ctx.Repo.Repository.Id, idx) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
if err == models.ErrIssueNotExist { |
|
|
|
if err == models.ErrIssueNotExist { |
|
|
|
ctx.Handle(404, "issue.UpdateIssueLabel", err) |
|
|
|
ctx.Handle(404, "issue.UpdateIssueLabel(GetIssueByIndex)", err) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
ctx.Handle(500, "issue.UpdateIssueLabel(GetIssueByIndex)", err) |
|
|
|
ctx.Handle(500, "issue.UpdateIssueLabel(GetIssueByIndex)", err) |
|
|
|
} |
|
|
|
} |
|
|
@ -454,6 +454,17 @@ func UpdateIssueLabel(ctx *middleware.Context, params martini.Params) { |
|
|
|
|
|
|
|
|
|
|
|
isAttach := ctx.Query("action") == "attach" |
|
|
|
isAttach := ctx.Query("action") == "attach" |
|
|
|
labelStrId := ctx.Query("id") |
|
|
|
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+"|") |
|
|
|
isHad := strings.Contains(issue.LabelIds, "$"+labelStrId+"|") |
|
|
|
isNeedUpdate := false |
|
|
|
isNeedUpdate := false |
|
|
|
if isAttach { |
|
|
|
if isAttach { |
|
|
@ -473,6 +484,22 @@ func UpdateIssueLabel(ctx *middleware.Context, params martini.Params) { |
|
|
|
ctx.Handle(500, "issue.UpdateIssueLabel(UpdateIssue)", err) |
|
|
|
ctx.Handle(500, "issue.UpdateIssueLabel(UpdateIssue)", err) |
|
|
|
return |
|
|
|
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{}{ |
|
|
|
ctx.JSON(200, map[string]interface{}{ |
|
|
|
"ok": true, |
|
|
|
"ok": true, |
|
|
|