From 21864f6898dd69594ed5fe707d63aa8f267f04b8 Mon Sep 17 00:00:00 2001
From: Lubomír Sedlář <lsedlar@redhat.com>
Date: May 26 2016 12:41:55 +0000
Subject: [PATCH 1/3] Fix add milestone button


---

diff --git a/pagure/templates/settings.html b/pagure/templates/settings.html
index 4187126..d68e456 100644
--- a/pagure/templates/settings.html
+++ b/pagure/templates/settings.html
@@ -479,7 +479,7 @@
           <div class="row p-t-1">
             <div class="col-sm-6">
               <a class="btn btn-secondary btn-sm btn-block" id="new_milestone">
-                  Add new priority
+                  Add new milestone
               </a>
             </div>
           </div>

From 1643598baa14e9c1b9e6330ca504fa20bc886599 Mon Sep 17 00:00:00 2001
From: Lubomír Sedlář <lsedlar@redhat.com>
Date: May 26 2016 12:42:20 +0000
Subject: [PATCH 2/3] Verify unique milestone date only if non-empty


It should be possible to have multiple milestones without dates. Without
this patch, trying to create a second milestone without date would
result in unclear error message "Date is present 2 times".

---

diff --git a/pagure/ui/repo.py b/pagure/ui/repo.py
index 42d552d..644d393 100644
--- a/pagure/ui/repo.py
+++ b/pagure/ui/repo.py
@@ -1087,7 +1087,7 @@ def update_milestones(repo, username=None):
                 break
 
         for milestone_date in milestone_dates:
-            if milestone_dates.count(milestone_date) != 1:
+            if milestone_date and milestone_dates.count(milestone_date) != 1:
                 flask.flash(
                     'Date %s is present %s times' % (
                         milestone_date, milestone_dates.count(milestone_date)
diff --git a/tests/test_pagure_flask_ui_roadmap.py b/tests/test_pagure_flask_ui_roadmap.py
index 9cc94f4..9f514d6 100644
--- a/tests/test_pagure_flask_ui_roadmap.py
+++ b/tests/test_pagure_flask_ui_roadmap.py
@@ -339,6 +339,38 @@ class PagureFlaskRoadmaptests(tests.Modeltests):
 
     @patch('pagure.lib.git.update_git')
     @patch('pagure.lib.notify.send_email')
+    def test_milestones_without_dates(self, p_send_email, p_ugt):
+        """ Test creating two milestones with no dates. """
+        tests.create_projects(self.session)
+        tests.create_projects_git(os.path.join(tests.HERE), bare=True)
+
+        user = tests.FakeUser()
+        user.username = 'pingou'
+        with tests.user_set(pagure.APP, user):
+            # Get the CSRF token
+            output = self.app.get('/test/settings')
+            csrf_token = output.data.split(
+                'name="csrf_token" type="hidden" value="')[1].split('">')[0]
+
+            data = {
+                'milestones': ['v1.0', 'v2.0'],
+                'milestone_dates': ['', ''],
+                'csrf_token': csrf_token,
+            }
+            output = self.app.post(
+                '/test/update/milestones', data=data, follow_redirects=True)
+            self.assertEqual(output.status_code, 200)
+            # Check the redirect
+            self.assertIn(
+                u'<title>Settings - test - Pagure</title>', output.data)
+            self.assertIn(u'<h3>Settings for test</h3>', output.data)
+            self.assertIn(u'Milestones updated', output.data)
+            # Check the result of the action -- Milestones recorded
+            repo = pagure.lib.get_project(self.session, 'test')
+            self.assertEqual(repo.milestones, {u'v1.0': u'', u'v2.0': u''})
+
+    @patch('pagure.lib.git.update_git')
+    @patch('pagure.lib.notify.send_email')
     def test_roadmap_ui(self, p_send_email, p_ugt):
         """ Test viewing the roadmap of a repo. """
         p_send_email.return_value = True

From c17e2c72b3f89499cb91a774b6abaa8a7d9e49cc Mon Sep 17 00:00:00 2001
From: Lubomír Sedlář <lsedlar@redhat.com>
Date: May 26 2016 12:42:32 +0000
Subject: [PATCH 3/3] Use links for switching to roadmap


Instead of nesting buttons inside a link, use just a link. This gets rid
of the extra underline between the buttons on hover.

---

diff --git a/pagure/templates/issues.html b/pagure/templates/issues.html
index e1b2ba4..d664157 100644
--- a/pagure/templates/issues.html
+++ b/pagure/templates/issues.html
@@ -16,12 +16,14 @@
     <span class="btn-group btn-group-sm pull-xs-right" role="group">
     {% if repo.milestones %}
       <a href="{{ url_for(
-          'view_roadmap', username=username, repo=repo.name) }}">
-        <button class="btn btn-default btn-sm">Roadmap</button>
+          'view_roadmap', username=username, repo=repo.name) }}"
+         class="btn btn-secondary btn-sm">
+        Roadmap
       </a>
     {% endif %}
-      <a href="{{ url_for('new_issue', username=username, repo=repo.name) }}">
-        <button class="btn btn-success btn-sm">New Issue</button>
+      <a href="{{ url_for('new_issue', username=username, repo=repo.name) }}"
+         class="btn btn-success btn-sm">
+        New Issue
       </a>
     </span>
   </h2>
diff --git a/pagure/templates/roadmap.html b/pagure/templates/roadmap.html
index 8ca9cee..6e42ebe 100644
--- a/pagure/templates/roadmap.html
+++ b/pagure/templates/roadmap.html
@@ -11,11 +11,13 @@
     {{ issues|count }} Milestones
     <span class="btn-group btn-group-sm pull-xs-right" role="group">
       <a href="{{ url_for(
-          'view_issues', username=username, repo=repo.name) }}">
-        <button class="btn btn-default btn-sm">List</button>
+          'view_issues', username=username, repo=repo.name) }}"
+         class="btn btn-secondary btn-sm">
+        List
       </a>
-      <a href="{{ url_for('new_issue', username=username, repo=repo.name) }}">
-        <button class="btn btn-success btn-sm">New Issue</button>
+      <a href="{{ url_for('new_issue', username=username, repo=repo.name) }}"
+          class="btn btn-success btn-sm">
+        New Issue
       </a>
     </span>
   </h2>

