From f0a464bd19dc9033cbdc61dcce05568fe8fbf262 Mon Sep 17 00:00:00 2001
From: Vivek Anand <vivekanand1101@gmail.com>
Date: May 30 2016 21:19:28 +0000
Subject: [PATCH 1/6] check if issue tracker is on, before showing issues on index page


---

diff --git a/pagure/templates/index_auth.html b/pagure/templates/index_auth.html
index fbeaa6b..fe7e9c2 100644
--- a/pagure/templates/index_auth.html
+++ b/pagure/templates/index_auth.html
@@ -49,34 +49,36 @@
                   <strong>{{ repo.name }}</strong>
                 </a>
                   <div class="pull-xs-right">
-                    {% if repo.open_tickets_public == 0 %}
-                      <span class="text-muted" data-toggle="tooltip"
-                        title="{{ repo.open_tickets_public }} open issues against {{repo.name}}">
-                        <span class="oi" data-glyph="warning"></span>
-                        {{- repo.open_tickets_public }}
-                      </span>
-                    {% else %}
-                      <a class="notblue" data-toggle="tooltip"
-                        href="{{ url_for('.view_issues', repo=repo.name) }}"
-                        title="{{ repo.open_tickets_public }} open issues against {{repo.name}}">
-                        <span class="oi" data-glyph="warning"></span>
-                        {{- repo.open_tickets_public }}
-                      </a>
-                    {% endif %}
+                      {% if config.get('ENABLE_TICKETS', True) %}
+                        {% if repo.open_tickets_public == 0 %}
+                        <span class="text-muted" data-toggle="tooltip"
+                            title="{{ repo.open_tickets_public }} open issues against {{repo.name}}">
+                            <span class="oi" data-glyph="warning"></span>
+                            {{- repo.open_tickets_public }}
+                        </span>
+                        {% else %}
+                        <a class="notblue" data-toggle="tooltip"
+                            href="{{ url_for('.view_issues', repo=repo.name) }}"
+                            title="{{ repo.open_tickets_public }} open issues against {{repo.name}}">
+                            <span class="oi" data-glyph="warning"></span>
+                            {{- repo.open_tickets_public }}
+                        </a>
+                        {% endif %}
+                      {% endif %}
 
                     {% if repo.open_requests == 0 %}
-                      <span class="text-muted" data-toggle="tooltip"
+                        <span class="text-muted" data-toggle="tooltip"
                         title="{{repo.open_requests}} open pull requests in {{repo.name}}">
                         <span class="oi" data-glyph="arrow-thick-bottom"></span>
                         {{- repo.open_requests}}
-                      </span>
+                        </span>
                     {% else %}
-                      <a class="notblue" data-toggle="tooltip"
+                        <a class="notblue" data-toggle="tooltip"
                         href="{{ url_for('.request_pulls', repo=repo.name) }}"
                         title="{{repo.open_requests}} open pull requests in {{repo.name}}">
                         <span class="oi" data-glyph="arrow-thick-bottom"></span>
                         {{- repo.open_requests}}
-                      </a>
+                        </a>
                     {% endif %}
 
                   </div>

From 2caeeda52d1cf9a3c08f84f88053ba31bc0bca56 Mon Sep 17 00:00:00 2001
From: Vivek Anand <vivekanand1101@gmail.com>
Date: May 30 2016 21:19:28 +0000
Subject: [PATCH 2/6] Disable editiing/deleting tag associated with the issues of a project, if issue tracker is disabled for the project


---

diff --git a/pagure/ui/issues.py b/pagure/ui/issues.py
index 8893408..a19296c 100644
--- a/pagure/ui/issues.py
+++ b/pagure/ui/issues.py
@@ -259,7 +259,7 @@ def update_issue(repo, issueid, username=None):
 @APP.route('/fork/<username>/<repo:repo>/tag/<tag>/edit', methods=('GET', 'POST'))
 @login_required
 def edit_tag(repo, tag, username=None):
-    """ Edit the specified tag of a project.
+    """ Edit the specified tag associated with the issues of a project.
     """
     repo = pagure.lib.get_project(SESSION, repo, user=username)
 
@@ -269,7 +269,11 @@ def edit_tag(repo, tag, username=None):
     if not is_repo_admin(repo):
         flask.abort(
             403,
-            'You are not allowed to edt tags of this project')
+            'You are not allowed to edit tags associated with the issues of \
+            this project')
+
+    if not repo.settings.get('issue_tracker', True):
+        flask.abort(404, 'No issue tracker found for this project')
 
     form = pagure.forms.AddIssueTagForm()
     if form.validate_on_submit():
@@ -306,7 +310,7 @@ def edit_tag(repo, tag, username=None):
 @APP.route('/fork/<username>/<repo:repo>/droptag/', methods=['POST'])
 @login_required
 def remove_tag(repo, username=None):
-    """ Remove the specified tag from the project.
+    """ Remove the specified tag, associated with the issues, from the project.
     """
     repo = pagure.lib.get_project(SESSION, repo, user=username)
 
@@ -316,7 +320,11 @@ def remove_tag(repo, username=None):
     if not is_repo_admin(repo):
         flask.abort(
             403,
-            'You are not allowed to remove tags of this project')
+            'You are not allowed to remove tags associated with the issues \
+            of this project')
+
+    if not repo.settings.get('issue_tracker', True):
+        flask.abort(404, 'No issue tracker found for this project')
 
     form = pagure.forms.AddIssueTagForm()
     if form.validate_on_submit():

From 89a4a8e440e86de6ca3d3c20cb9f98b02e7c85e2 Mon Sep 17 00:00:00 2001
From: Vivek Anand <vivekanand1101@gmail.com>
Date: May 30 2016 21:19:28 +0000
Subject: [PATCH 3/6] don't show issues in index page if the issue tracker is turned off for the repo


---

diff --git a/pagure/templates/index_auth.html b/pagure/templates/index_auth.html
index fe7e9c2..ffa1d5d 100644
--- a/pagure/templates/index_auth.html
+++ b/pagure/templates/index_auth.html
@@ -49,7 +49,7 @@
                   <strong>{{ repo.name }}</strong>
                 </a>
                   <div class="pull-xs-right">
-                      {% if config.get('ENABLE_TICKETS', True) %}
+                      {% if config.get('ENABLE_TICKETS', True) and repo.settings.get('issue_tracker', True) %}
                         {% if repo.open_tickets_public == 0 %}
                         <span class="text-muted" data-toggle="tooltip"
                             title="{{ repo.open_tickets_public }} open issues against {{repo.name}}">

From 5304994cc8ac697ab489fd4e4700b14973f78a4e Mon Sep 17 00:00:00 2001
From: Vivek Anand <vivekanand1101@gmail.com>
Date: May 30 2016 21:19:28 +0000
Subject: [PATCH 4/6] show msg if project creation not allowed on the pagure instance


---

diff --git a/pagure/ui/app.py b/pagure/ui/app.py
index 71877a2..b688dd6 100644
--- a/pagure/ui/app.py
+++ b/pagure/ui/app.py
@@ -364,7 +364,8 @@ def new_project():
     user = pagure.lib.search_user(SESSION, username=flask.g.fas_user.username)
 
     if not pagure.APP.config.get('ENABLE_NEW_PROJECTS', True):
-        flask.abort(404)
+        flask.abort(404, 'Creation of new project is not allowed on this \
+                pagure instance')
 
     form = pagure.forms.ProjectForm()
     if form.validate_on_submit():

From 58143d24a066d965b809e40cc96bbdf087f0ddde Mon Sep 17 00:00:00 2001
From: Vivek Anand <vivekanand1101@gmail.com>
Date: May 30 2016 21:19:28 +0000
Subject: [PATCH 5/6] check for user management key before adding/removing user from the repo


---

diff --git a/pagure/ui/repo.py b/pagure/ui/repo.py
index 447bf22..7525a0a 100644
--- a/pagure/ui/repo.py
+++ b/pagure/ui/repo.py
@@ -1269,6 +1269,10 @@ def new_repo_hook_token(repo, username=None):
 def remove_user(repo, userid, username=None):
     """ Remove the specified user from the project.
     """
+
+    if not pagure.APP.config.get('ENABLE_USER_MNGT', True):
+        flask.abort(404, 'User management not allowed in the pagure instance')
+
     if admin_session_timedout():
         flask.flash('Action canceled, try it again', 'error')
         url = flask.url_for(
@@ -1324,8 +1328,9 @@ def remove_user(repo, userid, username=None):
 def add_user(repo, username=None):
     """ Add the specified user from the project.
     """
+
     if not pagure.APP.config.get('ENABLE_USER_MNGT', True):
-        flask.abort(404)
+        flask.abort(404, 'User management is not allowed in this pagure instance')
 
     if admin_session_timedout():
         if flask.request.method == 'POST':
@@ -1381,6 +1386,10 @@ def add_user(repo, username=None):
 def remove_group_project(repo, groupid, username=None):
     """ Remove the specified group from the project.
     """
+
+    if not pagure.APP.config.get('ENABLE_USER_MNGT', True):
+        flask.abort(404, 'User management is not allowed in this pagure instance')
+
     if admin_session_timedout():
         flask.flash('Action canceled, try it again', 'error')
         url = flask.url_for(
@@ -1436,8 +1445,9 @@ def remove_group_project(repo, groupid, username=None):
 def add_group_project(repo, username=None):
     """ Add the specified group from the project.
     """
+
     if not pagure.APP.config.get('ENABLE_USER_MNGT', True):
-        flask.abort(404)
+        flask.abort(404, 'User management is not allowed in this pagure instance')
 
     if admin_session_timedout():
         if flask.request.method == 'POST':

From f7213d1a901ce778fdec152bc67f1858f4f9d875 Mon Sep 17 00:00:00 2001
From: Vivek Anand <vivekanand1101@gmail.com>
Date: May 30 2016 22:01:00 +0000
Subject: [PATCH 6/6] fix html indentation in the index page


---

diff --git a/pagure/templates/index_auth.html b/pagure/templates/index_auth.html
index ffa1d5d..7f87988 100644
--- a/pagure/templates/index_auth.html
+++ b/pagure/templates/index_auth.html
@@ -49,36 +49,36 @@
                   <strong>{{ repo.name }}</strong>
                 </a>
                   <div class="pull-xs-right">
-                      {% if config.get('ENABLE_TICKETS', True) and repo.settings.get('issue_tracker', True) %}
-                        {% if repo.open_tickets_public == 0 %}
+                    {% if config.get('ENABLE_TICKETS', True) and repo.settings.get('issue_tracker', True) %}
+                      {% if repo.open_tickets_public == 0 %}
                         <span class="text-muted" data-toggle="tooltip"
-                            title="{{ repo.open_tickets_public }} open issues against {{repo.name}}">
-                            <span class="oi" data-glyph="warning"></span>
-                            {{- repo.open_tickets_public }}
+                          title="{{ repo.open_tickets_public }} open issues against {{repo.name}}">
+                          <span class="oi" data-glyph="warning"></span>
+                          {{- repo.open_tickets_public }}
                         </span>
-                        {% else %}
+                      {% else %}
                         <a class="notblue" data-toggle="tooltip"
-                            href="{{ url_for('.view_issues', repo=repo.name) }}"
-                            title="{{ repo.open_tickets_public }} open issues against {{repo.name}}">
-                            <span class="oi" data-glyph="warning"></span>
-                            {{- repo.open_tickets_public }}
+                          href="{{ url_for('.view_issues', repo=repo.name) }}"
+                          title="{{ repo.open_tickets_public }} open issues against {{repo.name}}">
+                          <span class="oi" data-glyph="warning"></span>
+                          {{- repo.open_tickets_public }}
                         </a>
-                        {% endif %}
                       {% endif %}
+                    {% endif %}
 
                     {% if repo.open_requests == 0 %}
-                        <span class="text-muted" data-toggle="tooltip"
+                      <span class="text-muted" data-toggle="tooltip"
                         title="{{repo.open_requests}} open pull requests in {{repo.name}}">
                         <span class="oi" data-glyph="arrow-thick-bottom"></span>
                         {{- repo.open_requests}}
-                        </span>
+                      </span>
                     {% else %}
-                        <a class="notblue" data-toggle="tooltip"
+                      <a class="notblue" data-toggle="tooltip"
                         href="{{ url_for('.request_pulls', repo=repo.name) }}"
                         title="{{repo.open_requests}} open pull requests in {{repo.name}}">
                         <span class="oi" data-glyph="arrow-thick-bottom"></span>
                         {{- repo.open_requests}}
-                        </a>
+                      </a>
                     {% endif %}
 
                   </div>

