From ec26b78d3cf1a72d0895ce37dc37b3f9cc3c11ea Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Justin=20Nu=C3=9F?= <justin.nuss@hmmh.de>
Date: Tue, 22 Jul 2014 13:50:34 +0200
Subject: [PATCH] Fix issue #280. Update milestone counter when creating an
 issue

---
 models/issue.go | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/models/issue.go b/models/issue.go
index baf710a5e..c370af363 100644
--- a/models/issue.go
+++ b/models/issue.go
@@ -108,7 +108,17 @@ func NewIssue(issue *Issue) (err error) {
 		sess.Rollback()
 		return err
 	}
-	return sess.Commit()
+
+	if err = sess.Commit(); err != nil {
+		return err
+	}
+
+	if issue.MilestoneId > 0 {
+		// FIXES(280): Update milestone counter.
+		return ChangeMilestoneAssign(0, issue.MilestoneId, issue)
+	}
+
+	return
 }
 
 // GetIssueByIndex returns issue by given index in repository.