|
|
@ -53,11 +53,17 @@ func Issues(ctx *middleware.Context) { |
|
|
|
filterMode = models.FM_MENTION |
|
|
|
filterMode = models.FM_MENTION |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
mid, _ := base.StrTo(ctx.Query("milestone")).Int64() |
|
|
|
midx, _ := base.StrTo(ctx.Query("milestone")).Int64() |
|
|
|
|
|
|
|
mile, err := models.GetMilestoneByIndex(ctx.Repo.Repository.Id, midx) |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
ctx.Handle(500, "issue.Issues(GetMilestoneByIndex): %v", err) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
page, _ := base.StrTo(ctx.Query("page")).Int() |
|
|
|
page, _ := base.StrTo(ctx.Query("page")).Int() |
|
|
|
|
|
|
|
|
|
|
|
// Get issues.
|
|
|
|
// Get issues.
|
|
|
|
issues, err := models.GetIssues(assigneeId, ctx.Repo.Repository.Id, posterId, mid, page, |
|
|
|
issues, err := models.GetIssues(assigneeId, ctx.Repo.Repository.Id, posterId, mile.Id, page, |
|
|
|
isShowClosed, ctx.Query("labels"), ctx.Query("sortType")) |
|
|
|
isShowClosed, ctx.Query("labels"), ctx.Query("sortType")) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
ctx.Handle(500, "issue.Issues(GetIssues): %v", err) |
|
|
|
ctx.Handle(500, "issue.Issues(GetIssues): %v", err) |
|
|
@ -240,12 +246,37 @@ func ViewIssue(ctx *middleware.Context, params martini.Params) { |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
us, err := models.GetCollaborators(strings.TrimPrefix(ctx.Repo.RepoLink, "/")) |
|
|
|
// Get assigned milestone.
|
|
|
|
|
|
|
|
if issue.MilestoneId > 0 { |
|
|
|
|
|
|
|
ctx.Data["Milestone"], err = models.GetMilestoneById(issue.MilestoneId) |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
if err == models.ErrMilestoneNotExist { |
|
|
|
|
|
|
|
log.Warn("issue.ViewIssue(GetMilestoneById): %v", err) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
ctx.Handle(500, "issue.ViewIssue(GetMilestoneById)", err) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Get all milestones.
|
|
|
|
|
|
|
|
ctx.Data["OpenMilestones"], err = models.GetMilestones(ctx.Repo.Repository.Id, false) |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
ctx.Handle(500, "issue.ViewIssue(GetMilestones.1): %v", err) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
ctx.Data["ClosedMilestones"], err = models.GetMilestones(ctx.Repo.Repository.Id, true) |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
ctx.Handle(500, "issue.ViewIssue(GetMilestones.2): %v", err) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Get all collaborators.
|
|
|
|
|
|
|
|
ctx.Data["Collaborators"], err = models.GetCollaborators(strings.TrimPrefix(ctx.Repo.RepoLink, "/")) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
ctx.Handle(500, "issue.CreateIssue(GetCollaborators)", err) |
|
|
|
ctx.Handle(500, "issue.CreateIssue(GetCollaborators)", err) |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
ctx.Data["Collaborators"] = us |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ctx.IsSigned { |
|
|
|
if ctx.IsSigned { |
|
|
|
// Update issue-user.
|
|
|
|
// Update issue-user.
|
|
|
@ -331,6 +362,52 @@ func UpdateIssue(ctx *middleware.Context, params martini.Params, form auth.Creat |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func UpdateIssueMilestone(ctx *middleware.Context) { |
|
|
|
|
|
|
|
if !ctx.Repo.IsOwner { |
|
|
|
|
|
|
|
ctx.Error(403) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
issueId, err := base.StrTo(ctx.Query("issue")).Int64() |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
ctx.Error(404) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
issue, err := models.GetIssueById(issueId) |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
if err == models.ErrIssueNotExist { |
|
|
|
|
|
|
|
ctx.Handle(404, "issue.UpdateIssueMilestone(GetIssueById)", err) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
ctx.Handle(500, "issue.UpdateIssueMilestone(GetIssueById)", err) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
oldMid := issue.MilestoneId |
|
|
|
|
|
|
|
mid, _ := base.StrTo(ctx.Query("milestone")).Int64() |
|
|
|
|
|
|
|
if oldMid == mid { |
|
|
|
|
|
|
|
ctx.JSON(200, map[string]interface{}{ |
|
|
|
|
|
|
|
"ok": true, |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Not check for invalid milestone id and give responsibility to owners.
|
|
|
|
|
|
|
|
issue.MilestoneId = mid |
|
|
|
|
|
|
|
if err = models.ChangeMilestoneAssign(oldMid, mid, issue.IsClosed); err != nil { |
|
|
|
|
|
|
|
ctx.Handle(500, "issue.UpdateIssueMilestone(ChangeMilestoneAssign)", err) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} else if err = models.UpdateIssue(issue); err != nil { |
|
|
|
|
|
|
|
ctx.Handle(500, "issue.UpdateIssueMilestone(UpdateIssue)", err) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ctx.JSON(200, map[string]interface{}{ |
|
|
|
|
|
|
|
"ok": true, |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func UpdateAssignee(ctx *middleware.Context) { |
|
|
|
func UpdateAssignee(ctx *middleware.Context) { |
|
|
|
if !ctx.Repo.IsOwner { |
|
|
|
if !ctx.Repo.IsOwner { |
|
|
|
ctx.Error(403) |
|
|
|
ctx.Error(403) |
|
|
@ -580,6 +657,7 @@ func UpdateMilestone(ctx *middleware.Context, params martini.Params) { |
|
|
|
} |
|
|
|
} |
|
|
|
case "close": |
|
|
|
case "close": |
|
|
|
if !mile.IsClosed { |
|
|
|
if !mile.IsClosed { |
|
|
|
|
|
|
|
mile.ClosedDate = time.Now() |
|
|
|
if err = models.ChangeMilestoneStatus(mile, true); err != nil { |
|
|
|
if err = models.ChangeMilestoneStatus(mile, true); err != nil { |
|
|
|
ctx.Handle(500, "issue.UpdateMilestone(ChangeMilestoneStatus)", err) |
|
|
|
ctx.Handle(500, "issue.UpdateMilestone(ChangeMilestoneStatus)", err) |
|
|
|
return |
|
|
|
return |
|
|
|