From b70db618547b2167cac7e35be5405fb385512f30 Mon Sep 17 00:00:00 2001 From: Unknown Date: Wed, 14 May 2014 13:04:57 -0400 Subject: [PATCH] Fix #185 --- models/issue.go | 2 ++ models/repo.go | 26 ++++++++++++++++++++++---- routers/repo/issue.go | 1 + templates/issue/milestone.tmpl | 4 ++-- 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/models/issue.go b/models/issue.go index 3d3e433a42..7dd69267ae 100644 --- a/models/issue.go +++ b/models/issue.go @@ -167,6 +167,8 @@ type IssueUser struct { Uid int64 // User ID. IssueId int64 RepoId int64 + MilestoneId int64 + Labels string `xorm:"TEXT"` IsRead bool IsAssigned bool IsMentioned bool diff --git a/models/repo.go b/models/repo.go index 4382bd7dc5..0594c6c6f3 100644 --- a/models/repo.go +++ b/models/repo.go @@ -676,10 +676,6 @@ func DeleteRepository(userId, repoId int64, userName string) (err error) { sess.Rollback() return err } - if _, err = sess.Delete(&Issue{RepoId: repoId}); err != nil { - sess.Rollback() - return err - } if _, err = sess.Delete(&IssueUser{RepoId: repoId}); err != nil { sess.Rollback() return err @@ -688,6 +684,28 @@ func DeleteRepository(userId, repoId int64, userName string) (err error) { sess.Rollback() return err } + if _, err = sess.Delete(&Release{RepoId: repoId}); err != nil { + sess.Rollback() + return err + } + + // Delete comments. + if err = orm.Iterate(&Issue{RepoId: repoId}, func(idx int, bean interface{}) error { + issue := bean.(*Issue) + if _, err = sess.Delete(&Comment{IssueId: issue.Id}); err != nil { + sess.Rollback() + return err + } + return nil + }); err != nil { + sess.Rollback() + return err + } + + if _, err = sess.Delete(&Issue{RepoId: repoId}); err != nil { + sess.Rollback() + return err + } rawSql := "UPDATE `user` SET num_repos = num_repos - 1 WHERE id = ?" if _, err = sess.Exec(rawSql, userId); err != nil { diff --git a/routers/repo/issue.go b/routers/repo/issue.go index 7b8c912e69..db0eff9cde 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -63,6 +63,7 @@ func Issues(ctx *middleware.Context) { } mid = mile.Id } + fmt.Println(mid) page, _ := base.StrTo(ctx.Query("page")).Int() diff --git a/templates/issue/milestone.tmpl b/templates/issue/milestone.tmpl index ebf02d83af..8a5751c19b 100644 --- a/templates/issue/milestone.tmpl +++ b/templates/issue/milestone.tmpl @@ -19,8 +19,8 @@ {{range .Milestones}}

{{.Name}}

- {{.NumClosedIssues}} - {{.NumOpenIssues}} + {{.NumOpenIssues}} + {{.NumClosedIssues}}

Edit {{if .IsClosed}}