diff --git a/pagure/decorators.py b/pagure/decorators.py index bae71e1..c7d3262 100644 --- a/pagure/decorators.py +++ b/pagure/decorators.py @@ -37,6 +37,24 @@ def has_issue_tracker(function): return check_issue_tracker +def has_trackers(function): + """ + Decorator that checks if the current pagure project has the + issue tracker active or has PRs function active + If not active returns a 404 page + """ + + @wraps(function) + def check_trackers(*args, **kwargs): + repo = flask.g.repo + if not repo.settings.get("issue_tracker", True) and \ + not repo.settings.get("pull_requests", True): + flask.abort(404, "No ticket trackers found for this project") + return function(*args, **kwargs) + + return check_trackers + + def is_repo_admin(function): """ Decorator that checks if the current user is the admin of diff --git a/pagure/templates/settings.html b/pagure/templates/settings.html index 8d6eff2..77c3e69 100644 --- a/pagure/templates/settings.html +++ b/pagure/templates/settings.html @@ -59,8 +59,6 @@ href="#closestatus" role="tab" aria-controls="closestatus">Close Status Custom Issue Fields - Tags Reports {% endif %} @@ -68,6 +66,8 @@ {% if (config.get('ENABLE_TICKETS', True) and repo.settings.get('issue_tracker', True)) or repo.settings.get('pull_requests', True) %} + Tags Quick Replies {% endif %} @@ -896,90 +896,6 @@ -
-

- Tags -

-
-
-

- Here is the list of tags associated with this project (Issues and Pull Requests). -

-
    - {% for tag in tags %} -
  • - -   {{ tag.tag }} - -  {{tag.tag}} -  {{ tag.tag_description or '' }} -
    -
    - - {{ tag_form.csrf_token }} - -
    - - - -
    -
  • - {% endfor %} -
-
- {{ tag_form.csrf_token }} -
- -
-
- -
-
- -
-
-
-
-
-
-
- -

Reports @@ -1028,6 +944,89 @@ {% if (config.get('ENABLE_TICKETS', True) and repo.settings.get('issue_tracker', True)) or repo.settings.get('pull_requests', True) %} +
+

+ Tags +

+
+
+

+ Here is the list of tags associated with this project (Issues and Pull Requests). +

+
    + {% for tag in tags %} +
  • + +   {{ tag.tag }} + +  {{tag.tag}} +  {{ tag.tag_description or '' }} +
    +
    + + {{ tag_form.csrf_token }} + +
    + + + +
    +
  • + {% endfor %} +
+
+ {{ tag_form.csrf_token }} +
+ +
+
+ +
+
+ +
+
+
+
+
+
+
+

Quick Replies diff --git a/pagure/ui/issues.py b/pagure/ui/issues.py index a843c06..8d76a67 100644 --- a/pagure/ui/issues.py +++ b/pagure/ui/issues.py @@ -33,7 +33,8 @@ import pagure.doc_utils import pagure.exceptions import pagure.lib import pagure.lib.mimetype -from pagure.decorators import has_issue_tracker, is_repo_admin +from pagure.decorators import has_issue_tracker, is_repo_admin, has_trackers + import pagure.forms from pagure.config import config as pagure_config from pagure.ui import UI_NS @@ -566,7 +567,7 @@ def edit_tag(repo, tag, username=None, namespace=None): @UI_NS.route("///update/tags", methods=["POST"]) @login_required @is_repo_admin -@has_issue_tracker +@has_trackers def update_tags(repo, username=None, namespace=None): """ Update the tags of a project. """ diff --git a/pagure/ui/repo.py b/pagure/ui/repo.py index 8c70d5e..40ee3dc 100644 --- a/pagure/ui/repo.py +++ b/pagure/ui/repo.py @@ -58,6 +58,7 @@ from pagure.decorators import ( is_repo_admin, is_admin_sess_timedout, has_issue_tracker, + has_trackers, ) _log = logging.getLogger(__name__) @@ -2786,7 +2787,7 @@ def update_close_status(repo, username=None, namespace=None): methods=["POST"], ) @login_required -@has_issue_tracker +@has_trackers @is_admin_sess_timedout @is_repo_admin def update_quick_replies(repo, username=None, namespace=None): diff --git a/tests/test_pagure_flask_ui_issues.py b/tests/test_pagure_flask_ui_issues.py index e4df7bf..7cce469 100644 --- a/tests/test_pagure_flask_ui_issues.py +++ b/tests/test_pagure_flask_ui_issues.py @@ -3505,7 +3505,7 @@ class PagureFlaskIssuestests(tests.Modeltests): self.assertIn( 'blue\n' - '  ' + '  ' '', output_text) self.assertIn( '', @@ -3513,7 +3513,7 @@ class PagureFlaskIssuestests(tests.Modeltests): self.assertIn( 'red\n' - '  ' + '  ' 'lorem ipsum', output_text) self.assertIn( '', @@ -3535,7 +3535,7 @@ class PagureFlaskIssuestests(tests.Modeltests): self.assertIn( 'green\n' - '  ' + '  ' 'sample description', output_text) self.assertIn( '', @@ -3543,7 +3543,7 @@ class PagureFlaskIssuestests(tests.Modeltests): self.assertIn( 'red1\n' - '  ' + '  ' 'lorem ipsum', output_text) self.assertIn( '', @@ -3565,7 +3565,7 @@ class PagureFlaskIssuestests(tests.Modeltests): self.assertIn( 'red2\n' - '  ' + '  ' '', output_text) self.assertIn( '', @@ -3573,7 +3573,7 @@ class PagureFlaskIssuestests(tests.Modeltests): self.assertIn( 'red3\n' - '  ' + '  ' '', output_text) self.assertIn( '', @@ -3595,7 +3595,7 @@ class PagureFlaskIssuestests(tests.Modeltests): self.assertIn( 'red2\n' - '  ' + '  ' '', output_text) self.assertIn( '', @@ -3603,7 +3603,7 @@ class PagureFlaskIssuestests(tests.Modeltests): self.assertIn( 'red3\n' - '  ' + '  ' '', output_text) self.assertIn( '', @@ -3670,7 +3670,7 @@ class PagureFlaskIssuestests(tests.Modeltests): self.assertIn( 'is:red2\n' - '  ' + '  ' '', output_text) self.assertIn( '', diff --git a/tests/test_pagure_flask_ui_issues_read_only.py b/tests/test_pagure_flask_ui_issues_read_only.py index c5616a4..8187e7c 100644 --- a/tests/test_pagure_flask_ui_issues_read_only.py +++ b/tests/test_pagure_flask_ui_issues_read_only.py @@ -165,20 +165,6 @@ class PagureFlaskIssuesReadOnlytests(tests.Modeltests): '

The issue tracker for this project is read-only

', output_text) - def test_update_tags(self): - """ Test updating a ticket tag. - """ - user = tests.FakeUser(username='pingou') - with tests.user_set(self.app.application, user): - output = self.app.post('/test/update/tags', data={}) - self.assertEqual(output.status_code, 401) - output_text = output.get_data(as_text=True) - self.assertIn( - 'Unauthorized :\'( - Pagure', output_text) - self.assertIn( - '

The issue tracker for this project is read-only

', - output_text) - def test_drop_tags(self): """ Test dropping a ticket tag. """