From 0c6fd70c26a7e6946df0c42e93dcf1455b511d21 Mon Sep 17 00:00:00 2001
From: Vivek Anand <vivekanand1101@gmail.com>
Date: Jan 03 2018 16:36:40 +0000
Subject: [PATCH 1/2] Add project setting to show roadmap on issues page


Fixes #2003

Signed-off-by: Vivek Anand <vivekanand1101@gmail.com>

---

diff --git a/pagure/lib/model.py b/pagure/lib/model.py
index 12a1fde..837c549 100644
--- a/pagure/lib/model.py
+++ b/pagure/lib/model.py
@@ -519,6 +519,7 @@ class Project(BASE):
             'issues_default_to_private': False,
             'fedmsg_notifications': True,
             'pull_request_access_only': False,
+            'roadmap_on_issues_page': False,
         }
 
         if self._settings:
diff --git a/pagure/templates/repo_master.html b/pagure/templates/repo_master.html
index 4a0e005..23fe814 100644
--- a/pagure/templates/repo_master.html
+++ b/pagure/templates/repo_master.html
@@ -256,11 +256,16 @@
             <a {%
               if select == 'issues' %}class="active nav-link" {%
               else %}class="nav-link" {%
-              endif %}href="{{ url_for(
+              endif %}href={% if not repo.settings.get(
+                  'roadmap_on_issues_page', False) %}"{{ url_for(
                   'ui_ns.view_issues',
                   repo=repo.name,
                   username=username,
-                  namespace=repo.namespace) }}">
+                  namespace=repo.namespace) }}"{% else %}"{{ url_for(
+                  '.view_roadmap',
+                  repo=repo.name,
+                  username=username,
+                  namespace=repo.namespace) }}"{% endif %}>
                 <span class="oi hidden-md-up" data-glyph="warning"></span>
                 <span class="hidden-sm-down">Issues&nbsp;</span>
                 <span class="label label-default label-pill hidden-sm-down">
diff --git a/pagure/ui/issues.py b/pagure/ui/issues.py
index 6a472bc..3e15245 100644
--- a/pagure/ui/issues.py
+++ b/pagure/ui/issues.py
@@ -604,6 +604,7 @@ def remove_tag(repo, username=None, namespace=None):
 def view_issues(repo, username=None, namespace=None):
     """ List all issues associated to a repo
     """
+
     status = flask.request.args.get('status', 'Open')
     priority = flask.request.args.get('priority', None)
     tags = flask.request.args.getlist('tags')

From c62a5d36546f78a76fc37019281de2074a714348 Mon Sep 17 00:00:00 2001
From: Vivek Anand <vivekanand1101@gmail.com>
Date: Jan 03 2018 16:36:40 +0000
Subject: [PATCH 2/2] Unit test: view issues as roadmap view


Signed-off-by: Vivek Anand <vivekanand1101@gmail.com>

---

diff --git a/tests/test_pagure_flask_ui_issues.py b/tests/test_pagure_flask_ui_issues.py
index 8b40fd5..8874a8b 100644
--- a/tests/test_pagure_flask_ui_issues.py
+++ b/tests/test_pagure_flask_ui_issues.py
@@ -602,6 +602,43 @@ class PagureFlaskIssuestests(tests.Modeltests):
 
     @patch('pagure.lib.git.update_git')
     @patch('pagure.lib.notify.send_email')
+    def test_view_issues_roadmap_view(self, p_send_email, p_ugt):
+        """ Test the view_issues endpoint when view is set as roadmap view """
+        p_send_email.return_value = True
+        p_ugt.return_value = True
+
+        tests.create_projects(self.session)
+        tests.create_projects_git(
+            os.path.join(self.path, 'repos'), bare=True)
+
+        # Change settings to show roadmap on issue page
+        repo = pagure.get_authorized_project(self.session, 'test')
+        old_settings = repo.settings
+        old_settings['roadmap_on_issues_page'] = True
+        repo.settings = old_settings
+
+        self.session.add(repo)
+        self.session.commit()
+
+        # check on landing page of project for the URL that on the Issues tab
+        output = self.app.get('/test/')
+        self.assertEqual(output.status_code, 200)
+        self.assertIn('<a class="nav-link" href="/test/roadmap"', output.data)
+
+        # Revert and check
+        old_settings = repo.settings
+        old_settings['roadmap_on_issues_page'] = False
+        repo.settings = old_settings
+
+        self.session.add(repo)
+        self.session.commit()
+
+        output = self.app.get('/test/')
+        self.assertEqual(output.status_code, 200)
+        self.assertIn('<a class="nav-link" href="/test/issues"', output.data)
+
+    @patch('pagure.lib.git.update_git')
+    @patch('pagure.lib.notify.send_email')
     def test_view_issues(self, p_send_email, p_ugt):
         """ Test the view_issues endpoint. """
         p_send_email.return_value = True

