From 81ccc6008477484e599aeb297225f976838abe3a Mon Sep 17 00:00:00 2001 From: Vivek Anand Date: Feb 09 2017 09:03:18 +0000 Subject: [PATCH 1/9] Adjust repo settings frontend when ENABLE_TICKETS is False --- diff --git a/pagure/templates/settings.html b/pagure/templates/settings.html index 3d4fd97..57de712 100644 --- a/pagure/templates/settings.html +++ b/pagure/templates/settings.html @@ -269,6 +269,7 @@ Public notifications
+ {% if config.get('ENABLE_TICKETS', True) %}

The email addresses entered below will receive all the notifications related to (public) issue and pull-requests, this includes @@ -278,7 +279,18 @@

To enter multiple addresses, simply delimit then with a comma.

+ {% else %}
+

+ The email addresses entered below will receive all the notifications + related to and pull-requests, this includes + notifications about new pull-request, new comment + and status change. +

+

+ To enter multiple addresses, simply delimit then with a comma. +

+ {% endif %}
+ {% if config.get('ENABLE_TICKETS', True) %}
Issues notifications @@ -303,6 +316,7 @@
+ {% endif %}
Pull-requests notifications @@ -338,19 +352,21 @@ Re-generate git repos
- - - - {{ form.csrf_token }} - + {% if config.get('ENABLE_TICKETS', True) %} +
+ + + {{ form.csrf_token }} +
+ {% endif %}
{% set idcount = 1 %} {% for plugin in plugins %} + {% if not config.get('ENABLE_TICKETS', True) and plugin in ['Pagure tickets'] %} + {% else %}
{% set idcount = idcount+1 %} + {% endif %} {% endfor %}
From dacb02593e2b5c175736dfbdc047488a49cd08f4 Mon Sep 17 00:00:00 2001 From: Vivek Anand Date: Feb 09 2017 09:03:18 +0000 Subject: [PATCH 2/9] don't give option to make all issues as private by default if the issues are disabled on instance --- diff --git a/pagure/templates/settings.html b/pagure/templates/settings.html index 57de712..e8cf026 100644 --- a/pagure/templates/settings.html +++ b/pagure/templates/settings.html @@ -220,7 +220,7 @@ username=username, namespace=repo.namespace) }}" method="post"> {% for key in repo.settings | sort %} - {% if not config.get('ENABLE_TICKETS', True) and key in ['issue_tracker'] %} + {% if not config.get('ENABLE_TICKETS', True) and key in ['issue_tracker', 'issues_default_to_private'] %} {% elif not config.get('DOC_APP_URL') and key in ['project_documentation'] %} {% elif not config.get('WEBHOOK') and key in ['Web-hooks'] %} {% else %} From 6e91ca37bad50b48bbec6e9dea3c9dc75b42187f Mon Sep 17 00:00:00 2001 From: Vivek Anand Date: Feb 09 2017 09:03:18 +0000 Subject: [PATCH 3/9] No need to show "my issues" page when tickets is disabled on instance --- diff --git a/pagure/templates/master.html b/pagure/templates/master.html index 143d70e..a5a7295 100644 --- a/pagure/templates/master.html +++ b/pagure/templates/master.html @@ -70,9 +70,11 @@ url_for('user_settings') }}">My Settings - My Issues + {% if config.get('ENABLE_TICKETS', True) %} + My Issues + {% endif %} My Pull Requests diff --git a/pagure/ui/app.py b/pagure/ui/app.py index 936ba79..693ab36 100644 --- a/pagure/ui/app.py +++ b/pagure/ui/app.py @@ -373,6 +373,10 @@ def view_user_issues(username): :param username: The username to retrieve the issues for :type username: str """ + + if not APP.config.get('ENABLE_TICKETS', True): + flask.abort(404, 'Tickets have been disabled on this pagure instance') + user = pagure.lib.search_user(SESSION, username=username) if not user: flask.abort(404, 'No user `%s` found' % username) From 6e24c84e80b93eb025ae47e99687805757250870 Mon Sep 17 00:00:00 2001 From: Vivek Anand Date: Feb 09 2017 09:03:18 +0000 Subject: [PATCH 4/9] Allow viewing groups even when the user management is turned off --- diff --git a/pagure/templates/_browseheader.html b/pagure/templates/_browseheader.html index 99d3167..cbaaafb 100644 --- a/pagure/templates/_browseheader.html +++ b/pagure/templates/_browseheader.html @@ -29,12 +29,10 @@ else %}class="nav-link"{% endif %} href="{{ url_for('view_users') }}">Users - {% if config.get('ENABLE_USER_MNGT', True) %} - {% endif %} {%- endmacro %} From 0cb6f0652223d802763f32bada4fd229e4cfc405 Mon Sep 17 00:00:00 2001 From: Vivek Anand Date: Feb 09 2017 09:03:18 +0000 Subject: [PATCH 5/9] Add new exception: ProjectBlackListedException Signed-off-by: Vivek Anand --- diff --git a/pagure/exceptions.py b/pagure/exceptions.py index 80ee351..edcc943 100644 --- a/pagure/exceptions.py +++ b/pagure/exceptions.py @@ -23,6 +23,13 @@ class RepoExistsException(PagureException): pass +class ProjectBlackListedException(PagureException): + ''' Exception thrown when trying to create a repository but, that repository + name has been blacklisted + ''' + pass + + class FileNotFoundException(PagureException): ''' Exception thrown when trying to create a repository that already exists. diff --git a/pagure/lib/__init__.py b/pagure/lib/__init__.py index 01ab8fa..4cd4610 100644 --- a/pagure/lib/__init__.py +++ b/pagure/lib/__init__.py @@ -1104,7 +1104,7 @@ def new_project(session, user, name, blacklist, allowed_prefix, ''' if name in blacklist or ( namespace and '%s/%s' % (namespace, name) in blacklist): - raise pagure.exceptions.RepoExistsException( + raise pagure.exceptions.ProjectBlackListedException( 'No project "%s" are allowed to be created due to potential ' 'conflicts in URLs with pagure itself' % name ) From 611221557a36ce2c1c0a871762cfecf4c58e9f66 Mon Sep 17 00:00:00 2001 From: Vivek Anand Date: Feb 09 2017 09:03:18 +0000 Subject: [PATCH 6/9] Unit Test: Test my_issues view function when tickets if turned off on the instance Signed-off-by: Vivek Anand --- diff --git a/tests/test_pagure_flask_ui_app.py b/tests/test_pagure_flask_ui_app.py index 173d562..5b63e27 100644 --- a/tests/test_pagure_flask_ui_app.py +++ b/tests/test_pagure_flask_ui_app.py @@ -1196,6 +1196,16 @@ class PagureFlaskApptests(tests.Modeltests): self.assertEqual( output.data.count(' Date: Feb 09 2017 09:03:18 +0000 Subject: [PATCH 7/9] Unit Test: ProjectBlackListed Exception Signed-off-by: Vivek Anand --- diff --git a/tests/test_pagure_lib.py b/tests/test_pagure_lib.py index 33e40d8..f64b7ce 100644 --- a/tests/test_pagure_lib.py +++ b/tests/test_pagure_lib.py @@ -849,7 +849,7 @@ class PagureLibtests(tests.Modeltests): # Try creating a blacklisted project self.assertRaises( - pagure.exceptions.PagureException, + pagure.exceptions.ProjectBlackListedException, pagure.lib.new_project, session=self.session, user='pingou', From a9839210e0dac1dd77b89962cc66720c112d968f Mon Sep 17 00:00:00 2001 From: Vivek Anand Date: Feb 09 2017 09:03:18 +0000 Subject: [PATCH 8/9] turn on the ENABLE_TIKETS after the tests Signed-off-by: Vivek Anand --- diff --git a/tests/test_pagure_flask_ui_app.py b/tests/test_pagure_flask_ui_app.py index 5b63e27..3f2ecf2 100644 --- a/tests/test_pagure_flask_ui_app.py +++ b/tests/test_pagure_flask_ui_app.py @@ -1205,6 +1205,7 @@ class PagureFlaskApptests(tests.Modeltests): output = self.app.get('/user/pingou/issues') self.assertEqual(output.status_code, 404) + pagure.APP.config['ENABLE_TICKETS'] = True if __name__ == '__main__': From 3c0f86dc67e23a73c36f0f58ce4c33c34227d2f3 Mon Sep 17 00:00:00 2001 From: Vivek Anand Date: Feb 09 2017 09:03:18 +0000 Subject: [PATCH 9/9] Don't repeat lines when it can be avoided in settings.html Signed-off-by: Vivek Anand --- diff --git a/pagure/templates/settings.html b/pagure/templates/settings.html index e8cf026..c7dc777 100644 --- a/pagure/templates/settings.html +++ b/pagure/templates/settings.html @@ -269,28 +269,18 @@ Public notifications
- {% if config.get('ENABLE_TICKETS', True) %}

The email addresses entered below will receive all the notifications - related to (public) issue and pull-requests, this includes - notifications about new issue or pull-request, new comment + related to {% if config.get('ENABLE_TICKETS', True) %} + (public) issue and {% endif %}pull-requests, this includes + notifications about {% if config.get('ENABLE_TICKETS', True) %} + new issue or {% endif %} new pull-request, new comment and status change.

To enter multiple addresses, simply delimit then with a comma.

- {% else %}
-

- The email addresses entered below will receive all the notifications - related to and pull-requests, this includes - notifications about new pull-request, new comment - and status change. -

-

- To enter multiple addresses, simply delimit then with a comma. -

- {% endif %}