diff --git a/pagure/decorators.py b/pagure/decorators.py index 3e6e329..c00d958 100644 --- a/pagure/decorators.py +++ b/pagure/decorators.py @@ -58,6 +58,27 @@ def has_pr_enabled(function): return check_trackers +def has_issue_or_pr_enabled(function): + """ + Decorator that checks if the current pagure project has either their + issue tracker or their PR active. If both of them are disabled, it + returns a 404 page. + """ + + @wraps(function) + def check_issue_pr_trackers(*args, **kwargs): + repo = flask.g.repo + if not flask.g.issues_enabled and not repo.settings.get( + "pull_requests", True + ): + flask.abort( + 404, "Issue tracker and Pull-Request disabled for this project" + ) + return function(*args, **kwargs) + + return check_issue_pr_trackers + + def is_repo_admin(function): """ Decorator that checks if the current user is the admin of diff --git a/pagure/ui/repo.py b/pagure/ui/repo.py index deeb315..15afad5 100644 --- a/pagure/ui/repo.py +++ b/pagure/ui/repo.py @@ -60,6 +60,7 @@ from pagure.decorators import ( is_repo_admin, is_admin_sess_timedout, has_issue_tracker, + has_issue_or_pr_enabled, has_pr_enabled, ) @@ -3134,8 +3135,7 @@ def view_stats(repo, username=None, namespace=None): @UI_NS.route("///update/tags", methods=["POST"]) @login_required @is_repo_admin -@has_issue_tracker -@has_pr_enabled +@has_issue_or_pr_enabled def update_tags(repo, username=None, namespace=None): """ Update the tags of a project. """ @@ -3240,8 +3240,7 @@ def update_tags(repo, username=None, namespace=None): @UI_NS.route("/fork////droptag/", methods=["POST"]) @login_required @is_repo_admin -@has_issue_tracker -@has_pr_enabled +@has_issue_or_pr_enabled def remove_tag(repo, username=None, namespace=None): """ Remove the specified tag, associated with the issues, from the project. """ @@ -3294,8 +3293,7 @@ def remove_tag(repo, username=None, namespace=None): ) @login_required @is_repo_admin -@has_issue_tracker -@has_pr_enabled +@has_issue_or_pr_enabled def edit_tag(repo, tag, username=None, namespace=None): """ Edit the specified tag associated with the issues of a project. """