diff --git a/models/issue.go b/models/issue.go index 26380b603..3d3e433a4 100644 --- a/models/issue.go +++ b/models/issue.go @@ -543,18 +543,20 @@ func ChangeMilestoneAssign(oldMid, mid int64, isIssueClosed bool) (err error) { } } - m, err := GetMilestoneById(mid) - if err != nil { - return err - } - m.NumIssues++ - if isIssueClosed { - m.NumClosedIssues++ - } - m.Completeness = m.NumClosedIssues * 100 / m.NumIssues - if _, err = sess.Id(m.Id).Update(m); err != nil { - sess.Rollback() - return err + if mid > 0 { + m, err := GetMilestoneById(mid) + if err != nil { + return err + } + m.NumIssues++ + if isIssueClosed { + m.NumClosedIssues++ + } + m.Completeness = m.NumClosedIssues * 100 / m.NumIssues + if _, err = sess.Id(m.Id).Update(m); err != nil { + sess.Rollback() + return err + } } return sess.Commit() } diff --git a/routers/repo/issue.go b/routers/repo/issue.go index 2346539d0..7b8c912e6 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -53,17 +53,21 @@ func Issues(ctx *middleware.Context) { filterMode = models.FM_MENTION } + var mid 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 + if midx > 0 { + mile, err := models.GetMilestoneByIndex(ctx.Repo.Repository.Id, midx) + if err != nil { + ctx.Handle(500, "issue.Issues(GetMilestoneByIndex): %v", err) + return + } + mid = mile.Id } page, _ := base.StrTo(ctx.Query("page")).Int() // Get issues. - issues, err := models.GetIssues(assigneeId, ctx.Repo.Repository.Id, posterId, mile.Id, page, + issues, err := models.GetIssues(assigneeId, ctx.Repo.Repository.Id, posterId, mid, page, isShowClosed, ctx.Query("labels"), ctx.Query("sortType")) if err != nil { ctx.Handle(500, "issue.Issues(GetIssues): %v", err) @@ -120,6 +124,19 @@ func CreateIssue(ctx *middleware.Context, params martini.Params) { ctx.Data["IsRepoToolbarIssues"] = true ctx.Data["IsRepoToolbarIssuesList"] = false + var err error + // 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 + } + us, err := models.GetCollaborators(strings.TrimPrefix(ctx.Repo.RepoLink, "/")) if err != nil { ctx.Handle(500, "issue.CreateIssue(GetCollaborators)", err) @@ -134,6 +151,19 @@ func CreateIssuePost(ctx *middleware.Context, params martini.Params, form auth.C ctx.Data["IsRepoToolbarIssues"] = true ctx.Data["IsRepoToolbarIssuesList"] = false + var err error + // 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 + } + us, err := models.GetCollaborators(strings.TrimPrefix(ctx.Repo.RepoLink, "/")) if err != nil { ctx.Handle(500, "issue.CreateIssue(GetCollaborators)", err) diff --git a/templates/issue/create.tmpl b/templates/issue/create.tmpl index 4b43116cc..34cecc78b 100644 --- a/templates/issue/create.tmpl +++ b/templates/issue/create.tmpl @@ -48,25 +48,33 @@
+ {{if not .OpenMilestones}}

Nothing to show

+ {{else}} + {{end}}
+
+ {{if not .ClosedMilestones}} +

Nothing to show

+ {{else}} + {{end}}
diff --git a/templates/issue/view.tmpl b/templates/issue/view.tmpl index 5aeb9409e..18ec5faf0 100644 --- a/templates/issue/view.tmpl +++ b/templates/issue/view.tmpl @@ -100,7 +100,7 @@
-
+