From 6f029537892d4e7e865ca7d7369a44a2bbaf16bb Mon Sep 17 00:00:00 2001 From: Julen Landa Alustiza Date: Jan 10 2020 13:16:20 +0000 Subject: api/utils: check wether system wide tickets are enabled on _check_issue_tracker() --- diff --git a/pagure/api/__init__.py b/pagure/api/__init__.py index 3133150..d13e8ad 100644 --- a/pagure/api/__init__.py +++ b/pagure/api/__init__.py @@ -66,7 +66,7 @@ class APIERROR(enum.Enum): ENOCODE = "Variable message describing the issue" ENOPROJECT = "Project not found" ENOPROJECTS = "No projects found" - ETRACKERDISABLED = "Issue tracker disabled for this project" + ETRACKERDISABLED = "Issue tracker disabled" EDBERROR = ( "An error occurred at the database level and prevent the " + "action from reaching completion" diff --git a/pagure/api/utils.py b/pagure/api/utils.py index b1d1dd6..49178c4 100644 --- a/pagure/api/utils.py +++ b/pagure/api/utils.py @@ -111,12 +111,17 @@ def _check_issue_tracker(repo): :param repo: repository :raises pagure.exceptions.APIError: when issue tracker is disabled """ + enable_tickets = pagure_config.get("ENABLE_TICKETS") ticket_namespaces = pagure_config.get("ENABLE_TICKETS_NAMESPACE") if ( - ticket_namespaces - and repo.namespace - and repo.namespace not in ticket_namespaces - ) or not repo.settings.get("issue_tracker", True): + ( + ticket_namespaces + and repo.namespace + and repo.namespace not in ticket_namespaces + ) + or not enable_tickets + or not repo.settings.get("issue_tracker", True) + ): raise pagure.exceptions.APIError( 404, error_code=APIERROR.ETRACKERDISABLED ) diff --git a/tests/test_pagure_flask_api_issue.py b/tests/test_pagure_flask_api_issue.py index 273839b..b4cbff0 100644 --- a/tests/test_pagure_flask_api_issue.py +++ b/tests/test_pagure_flask_api_issue.py @@ -3954,7 +3954,7 @@ class PagureFlaskApiIssuetests(tests.SimplePagureTest): self.assertDictEqual( data, { - "error": "Issue tracker disabled for this project", + "error": "Issue tracker disabled", "error_code": "ETRACKERDISABLED", }, )