#1007 Make sure the config keys are working: issue trackers, create/delete project and user management.
Merged 7 years ago by pingou. Opened 7 years ago by vivekanand1101.
vivekanand1101/pagure working_keys  into  master

@@ -49,19 +49,21 @@ 

                    <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>

+                     {% 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 }}

+                         </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 %}

file modified
+2 -1
@@ -364,7 +364,8 @@ 

      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():

file modified
+12 -4
@@ -259,7 +259,7 @@ 

  @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 @@ 

      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 @@ 

  @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 @@ 

      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():

file modified
+12 -2
@@ -1269,6 +1269,10 @@ 

  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 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 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 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':

no initial comment

This was good as it was I think

A comment for the changes in the HTML, the rest looks good except for one aspect: unit-tests :)

rebased

7 years ago

6 new commits added

  • fix html indentation in the index page
  • check for user management key before adding/removing user from the repo
  • show msg if project creation not allowed on the pagure instance
  • don't show issues in index page if the issue tracker is turned off for the repo
  • Disable editiing/deleting tag associated with the issues of a project, if issue tracker is disabled for the project
  • check if issue tracker is on, before showing issues on index page
7 years ago

Pull-Request has been merged by pingou

7 years ago