From 0b4fcf12244c85653e92c87293f63024301d8a66 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Justin=20Nu=C3=9F?= <justin.nuss@hmmh.de>
Date: Tue, 22 Jul 2014 11:56:08 +0200
Subject: [PATCH 1/3] Fix unwatch button not working in Firefox

---
 public/js/app.js | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/public/js/app.js b/public/js/app.js
index 4c376ea08..88ddd471d 100644
--- a/public/js/app.js
+++ b/public/js/app.js
@@ -406,8 +406,10 @@ function initRepository() {
     // watching script
     (function () {
         var $watch = $('#repo-watching'),
-            watchLink = $watch.data("watch"),
-            unwatchLink = $watch.data("unwatch");
+        	watchLink = $watch.attr("data-watch"),
+            // Use $.attr() to work around jQuery not finding $.data("unwatch") in Firefox,
+            // which has a method "unwatch" on `Object` that gets returned instead.
+            unwatchLink = $watch.attr("data-unwatch");
         $watch.on('click', '.to-watch', function () {
             if ($watch.hasClass("watching")) {
                 return false;

From 18718afb363dbc4bb2545a73936add5f152ffc09 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Justin=20Nu=C3=9F?= <justin.nuss@hmmh.de>
Date: Tue, 22 Jul 2014 11:57:10 +0200
Subject: [PATCH 2/3] Hide watch/unwatch button if not loggedin

---
 templates/repo/nav.tmpl | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/templates/repo/nav.tmpl b/templates/repo/nav.tmpl
index ea7799b35..f6530fa1c 100644
--- a/templates/repo/nav.tmpl
+++ b/templates/repo/nav.tmpl
@@ -31,6 +31,7 @@
                         </div>
                     </div>
                 </div>
+                {{if .IsSigned}}
                 <div class="btn-group {{if .IsRepositoryWatching}}watching{{else}}no-watching{{end}}" id="repo-watching" data-watch="/{{.Owner.Name}}/{{.Repository.Name}}/action/watch" data-unwatch="/{{.Owner.Name}}/{{.Repository.Name}}/action/unwatch">
                     {{if .IsRepositoryWatching}}
                     <button type="button" class="btn btn-default"><i class="fa fa-eye fa-lg fa-m"></i></button>
@@ -52,6 +53,7 @@
                         </div>
                     </div>
                 </div>
+                {{end}}
                 <!-- <div class="btn-group">
                     <button type="button" class="btn btn-default" data-toggle="tooltip" data-placement="top" title="Star"><i class="fa fa-star"></i>&nbsp;{{.Repository.NumStars}}</button>
                 </div> -->

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 3/3] 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.