diff --git a/pagure/decorators.py b/pagure/decorators.py
index a4c700c..5fc3f10 100644
--- a/pagure/decorators.py
+++ b/pagure/decorators.py
@@ -29,12 +29,17 @@ def has_issue_tracker(function):
if not flask.g.issues_enabled or not repo.settings.get(
"issue_tracker", True
):
- flask.abort(404, "No issue tracker found for this project")
+ flask.abort(
+ 404, description="No issue tracker found for this project"
+ )
# forbid all POST requests if the issue tracker is made read-only
if flask.request.method == "POST" and repo.settings.get(
"issue_tracker_read_only", False
):
- flask.abort(401, "The issue tracker for this project is read-only")
+ flask.abort(
+ 401,
+ description="The issue tracker for this project is read-only",
+ )
return function(*args, **kwargs)
return check_issue_tracker
@@ -51,7 +56,10 @@ def has_pr_enabled(function):
def check_trackers(*args, **kwargs):
repo = flask.g.repo
if not repo.settings.get("pull_requests", True):
- flask.abort(404, "Pull Requests are not enabled on this project")
+ flask.abort(
+ 404,
+ description="Pull Requests are not enabled on this project",
+ )
return function(*args, **kwargs)
@@ -73,10 +81,15 @@ def has_issue_or_pr_enabled(function):
pr_enabled = repo.settings.get("pull_requests", True)
if not issue_enabled and not pr_enabled:
flask.abort(
- 404, "Issue tracker and Pull-Request disabled for this project"
+ 404,
+ description="Issue tracker and Pull-Request disabled for "
+ "this project",
)
elif flask.request.method == "POST" and not pr_enabled and issue_ro:
- flask.abort(401, "The issue tracker for this project is read-only")
+ flask.abort(
+ 401,
+ description="The issue tracker for this project is read-only",
+ )
return function(*args, **kwargs)
return check_issue_pr_trackers
@@ -94,7 +107,7 @@ def is_repo_admin(function):
if not flask.g.repo_admin:
flask.abort(
403,
- "You are not allowed to change the "
+ description="You are not allowed to change the "
"settings for this project",
)
return function(*args, **kwargs)
diff --git a/pagure/docs_server.py b/pagure/docs_server.py
index 1706c05..3878afc 100644
--- a/pagure/docs_server.py
+++ b/pagure/docs_server.py
@@ -118,7 +118,7 @@ def __get_tree_and_content(repo_obj, commit, path):
if not repo_obj[blob_or_tree.oid]:
# Not tested and no idea how to test it, but better safe than sorry
- flask.abort(404, "File not found")
+ flask.abort(404, description="File not found")
if isinstance(blob_or_tree, pygit2.TreeEntry): # Returned a file
filename = blob_or_tree.name
@@ -159,14 +159,14 @@ def view_docs(repo, username=None, namespace=None, filename=None):
)
if not repo:
- flask.abort(404, "Project not found")
+ flask.abort(404, description="Project not found")
if not repo.settings.get("project_documentation", True):
- flask.abort(404, "This project has documentation disabled")
+ flask.abort(404, description="This project has documentation disabled")
reponame = repo.repopath("docs")
if not os.path.exists(reponame):
- flask.abort(404, "Documentation not found")
+ flask.abort(404, description="Documentation not found")
repo_obj = pygit2.Repository(reponame)
@@ -199,11 +199,13 @@ def view_docs(repo, username=None, namespace=None, filename=None):
flask.flash("%s" % err, "error")
except Exception as err:
_log.exception(err)
- flask.abort(500, "Unkown error encountered and reported")
+ flask.abort(
+ 500, description="Unkown error encountered and reported"
+ )
if not content:
if not tree or not len(tree):
- flask.abort(404, "No content found in the repository")
+ flask.abort(404, description="No content found in the repository")
html = "
"
for el in tree:
name = el.name
diff --git a/pagure/flask_app.py b/pagure/flask_app.py
index d7a0e80..b6dbcd3 100644
--- a/pagure/flask_app.py
+++ b/pagure/flask_app.py
@@ -308,7 +308,10 @@ def set_request():
# Block all POST request from blocked users
if flask.g.repo and flask.request.method != "GET":
if flask.g.fas_user.username in flask.g.repo.block_users:
- flask.abort(403, "You have been blocked from this project")
+ flask.abort(
+ 403,
+ description="You have been blocked from this project",
+ )
if (
not flask.g.repo
@@ -327,7 +330,7 @@ def set_request():
)
if flask.g.repo is None:
- flask.abort(404, "Project not found")
+ flask.abort(404, description="Project not found")
# If issues are not globally enabled, there is no point in continuing
if flask.g.issues_enabled:
@@ -492,4 +495,4 @@ def _get_user(username):
try:
return pagure.lib.query.get_user(flask.g.session, username)
except pagure.exceptions.PagureException as e:
- flask.abort(404, "%s" % e)
+ flask.abort(404, description="%s" % e)
diff --git a/pagure/internal/__init__.py b/pagure/internal/__init__.py
index 3e892fe..f6bfba4 100644
--- a/pagure/internal/__init__.py
+++ b/pagure/internal/__init__.py
@@ -176,7 +176,7 @@ def pull_request_add_comment():
"""
pform = pagure.forms.ProjectCommentForm(csrf_enabled=False)
if not pform.validate_on_submit():
- flask.abort(400, "Invalid request")
+ flask.abort(400, description="Invalid request")
objid = pform.objid.data
useremail = pform.useremail.data
@@ -186,12 +186,12 @@ def pull_request_add_comment():
)
if not request:
- flask.abort(404, "Pull-request not found")
+ flask.abort(404, description="Pull-request not found")
form = pagure.forms.AddPullRequestCommentForm(csrf_enabled=False)
if not form.validate_on_submit():
- flask.abort(400, "Invalid request")
+ flask.abort(400, description="Invalid request")
commit = form.commit.data or None
tree_id = form.tree_id.data or None
@@ -214,7 +214,9 @@ def pull_request_add_comment():
except SQLAlchemyError as err: # pragma: no cover
flask.g.session.rollback()
_log.exception(err)
- flask.abort(500, "Error when saving the request to the database")
+ flask.abort(
+ 500, description="Error when saving the request to the database"
+ )
return flask.jsonify({"message": message})
@@ -226,7 +228,7 @@ def ticket_add_comment():
"""
pform = pagure.forms.ProjectCommentForm(csrf_enabled=False)
if not pform.validate_on_submit():
- flask.abort(400, "Invalid request")
+ flask.abort(400, description="Invalid request")
objid = pform.objid.data
useremail = pform.useremail.data
@@ -234,7 +236,7 @@ def ticket_add_comment():
issue = pagure.lib.query.get_issue_by_uid(flask.g.session, issue_uid=objid)
if issue is None:
- flask.abort(404, "Issue not found")
+ flask.abort(404, description="Issue not found")
user_obj = pagure.lib.query.search_user(flask.g.session, email=useremail)
admin = False
@@ -250,13 +252,15 @@ def ticket_add_comment():
and not issue.user.user == user_obj.username
):
flask.abort(
- 403, "This issue is private and you are not allowed to view it"
+ 403,
+ description="This issue is private and you are not allowed "
+ "to view it",
)
form = pagure.forms.CommentForm(csrf_enabled=False)
if not form.validate_on_submit():
- flask.abort(400, "Invalid request")
+ flask.abort(400, description="Invalid request")
comment = form.comment.data
@@ -272,7 +276,9 @@ def ticket_add_comment():
except SQLAlchemyError as err: # pragma: no cover
flask.g.session.rollback()
_log.exception(err)
- flask.abort(500, "Error when saving the request to the database")
+ flask.abort(
+ 500, description="Error when saving the request to the database"
+ )
return flask.jsonify({"message": message})
diff --git a/pagure/ui/app.py b/pagure/ui/app.py
index aa5a5e1..697c148 100644
--- a/pagure/ui/app.py
+++ b/pagure/ui/app.py
@@ -925,7 +925,10 @@ def view_user_issues(username):
"""
if not pagure_config.get("ENABLE_TICKETS", True):
- flask.abort(404, "Tickets have been disabled on this pagure instance")
+ flask.abort(
+ 404,
+ description="Tickets have been disabled on this pagure instance",
+ )
user = _get_user(username=username)
userprofile_common = get_userprofile_common(user)
@@ -1008,7 +1011,7 @@ def new_project():
) or not pagure_config.get("ENABLE_UI_NEW_PROJECTS", True):
flask.abort(
404,
- "Creation of new project is not allowed on this \
+ description="Creation of new project is not allowed on this \
pagure instance",
)
@@ -1270,7 +1273,7 @@ def markdown_preview():
if form.validate_on_submit():
return pagure.ui.filters.markdown_filter(flask.request.form["content"])
else:
- flask.abort(400, "Invalid request")
+ flask.abort(400, description="Invalid request")
@UI_NS.route("/settings/email/drop", methods=["POST"])
@@ -1529,7 +1532,7 @@ def revoke_api_user_token(token_id):
token = pagure.lib.query.get_api_token(flask.g.session, token_id)
if not token or token.user.username != flask.g.fas_user.username:
- flask.abort(404, "Token not found")
+ flask.abort(404, description="Token not found")
form = pagure.forms.ConfirmationForm()
diff --git a/pagure/ui/clone.py b/pagure/ui/clone.py
index 2c71b10..6839a18 100644
--- a/pagure/ui/clone.py
+++ b/pagure/ui/clone.py
@@ -213,7 +213,7 @@ def clone_proxy(project, username=None, namespace=None):
access to the attempted repository.
"""
if not pagure_config["ALLOW_HTTP_PULL_PUSH"]:
- flask.abort(403, "HTTP pull/push is not allowed")
+ flask.abort(403, description="HTTP pull/push is not allowed")
service = None
if flask.request.path.endswith("/info/refs"):
@@ -221,17 +221,17 @@ def clone_proxy(project, username=None, namespace=None):
if not service:
# This is a Git client older than 1.6.6, and it doesn't work with
# the smart protocol. We do not support the old protocol via HTTP.
- flask.abort(400, "Please switch to newer Git client")
+ flask.abort(400, description="Please switch to newer Git client")
if service not in ("git-upload-pack", "git-receive-pack"):
- flask.abort(400, "Unknown service requested")
+ flask.abort(400, description="Unknown service requested")
if "git-receive-pack" in flask.request.full_path:
if not pagure_config["ALLOW_HTTP_PUSH"]:
# Pushing (git-receive-pack) over HTTP is not allowed
- flask.abort(403, "HTTP pushing disabled")
+ flask.abort(403, description="HTTP pushing disabled")
if not flask.request.remote_user:
# Anonymous pushing... nope
- flask.abort(403, "Unauthenticated push not allowed")
+ flask.abort(403, description="Unauthenticated push not allowed")
project = pagure.lib.query.get_authorized_project(
flask.g.session,
@@ -241,7 +241,7 @@ def clone_proxy(project, username=None, namespace=None):
asuser=flask.request.remote_user,
)
if not project:
- flask.abort(404, "Project not found")
+ flask.abort(404, description="Project not found")
if project.is_on_repospanner:
return proxy_repospanner(project, service)
diff --git a/pagure/ui/fork.py b/pagure/ui/fork.py
index 3ebae01..da1cd03 100644
--- a/pagure/ui/fork.py
+++ b/pagure/ui/fork.py
@@ -78,7 +78,7 @@ def request_pulls(repo, username=None, namespace=None):
repo = flask.g.repo
if not repo.settings.get("pull_requests", True):
- flask.abort(404, "No pull-requests found for this project")
+ flask.abort(404, description="No pull-requests found for this project")
total_open = pagure.lib.query.search_pull_requests(
flask.g.session, project_id=repo.id, status=True, count=True
@@ -236,14 +236,14 @@ def request_pull(repo, requestid, username=None, namespace=None):
_log.info("Viewing pull Request #%s repo: %s", requestid, repo.fullname)
if not repo.settings.get("pull_requests", True):
- flask.abort(404, "No pull-requests found for this project")
+ flask.abort(404, description="No pull-requests found for this project")
request = pagure.lib.query.search_pull_requests(
flask.g.session, project_id=repo.id, requestid=requestid
)
if not request:
- flask.abort(404, "Pull-request not found")
+ flask.abort(404, description="Pull-request not found")
if request.remote:
repopath = pagure.utils.get_remote_repo_path(
@@ -405,14 +405,14 @@ def request_pull_to_diff_or_patch(
repo = flask.g.repo
if not repo.settings.get("pull_requests", True):
- flask.abort(404, "No pull-requests found for this project")
+ flask.abort(404, description="No pull-requests found for this project")
request = pagure.lib.query.search_pull_requests(
flask.g.session, project_id=repo.id, requestid=requestid
)
if not request:
- flask.abort(404, "Pull-request not found")
+ flask.abort(404, description="Pull-request not found")
if request.remote:
repopath = pagure.utils.get_remote_repo_path(
@@ -513,23 +513,25 @@ def request_pull_edit(repo, requestid, username=None, namespace=None):
repo = flask.g.repo
if not repo.settings.get("pull_requests", True):
- flask.abort(404, "No pull-requests found for this project")
+ flask.abort(404, description="No pull-requests found for this project")
request = pagure.lib.query.search_pull_requests(
flask.g.session, project_id=repo.id, requestid=requestid
)
if not request:
- flask.abort(404, "Pull-request not found")
+ flask.abort(404, description="Pull-request not found")
if request.status != "Open":
- flask.abort(400, "Pull-request is already closed")
+ flask.abort(400, description="Pull-request is already closed")
if (
not flask.g.repo_committer
and flask.g.fas_user.username != request.user.username
):
- flask.abort(403, "You are not allowed to edit this pull-request")
+ flask.abort(
+ 403, description="You are not allowed to edit this pull-request"
+ )
form = pagure.forms.RequestPullForm()
if form.validate_on_submit():
@@ -621,14 +623,14 @@ def pull_request_add_comment(
repo = flask.g.repo
if not repo.settings.get("pull_requests", True):
- flask.abort(404, "No pull-requests found for this project")
+ flask.abort(404, description="No pull-requests found for this project")
request = pagure.lib.query.search_pull_requests(
flask.g.session, project_id=repo.id, requestid=requestid
)
if not request:
- flask.abort(404, "Pull-request not found")
+ flask.abort(404, description="Pull-request not found")
is_js = flask.request.args.get("js", False)
tree_id = flask.request.args.get("tree_id") or None
@@ -721,17 +723,17 @@ def pull_request_drop_comment(repo, requestid, username=None, namespace=None):
repo = flask.g.repo
if not repo:
- flask.abort(404, "Project not found")
+ flask.abort(404, description="Project not found")
if not repo.settings.get("pull_requests", True):
- flask.abort(404, "No pull-requests found for this project")
+ flask.abort(404, description="No pull-requests found for this project")
request = pagure.lib.query.search_pull_requests(
flask.g.session, project_id=repo.id, requestid=requestid
)
if not request:
- flask.abort(404, "Pull-request not found")
+ flask.abort(404, description="Pull-request not found")
if flask.request.form.get("edit_comment"):
commentid = flask.request.form.get("edit_comment")
@@ -751,7 +753,7 @@ def pull_request_drop_comment(repo, requestid, username=None, namespace=None):
flask.g.session, request.uid, commentid
)
if comment is None or comment.pull_request.project != repo:
- flask.abort(404, "Comment not found")
+ flask.abort(404, description="Comment not found")
if (
flask.g.fas_user.username != comment.user.username
@@ -759,8 +761,8 @@ def pull_request_drop_comment(repo, requestid, username=None, namespace=None):
) and not flask.g.repo_committer:
flask.abort(
403,
- "You are not allowed to remove this comment from "
- "this issue",
+ description="You are not allowed to remove this comment "
+ "from this issue",
)
flask.g.session.delete(comment)
@@ -815,27 +817,27 @@ def pull_request_edit_comment(
project = flask.g.repo
if not project.settings.get("pull_requests", True):
- flask.abort(404, "No pull-requests found for this project")
+ flask.abort(404, description="No pull-requests found for this project")
request = pagure.lib.query.search_pull_requests(
flask.g.session, project_id=project.id, requestid=requestid
)
if not request:
- flask.abort(404, "Pull-request not found")
+ flask.abort(404, description="Pull-request not found")
comment = pagure.lib.query.get_request_comment(
flask.g.session, request.uid, commentid
)
if comment is None or comment.parent.project != project:
- flask.abort(404, "Comment not found")
+ flask.abort(404, description="Comment not found")
if (
flask.g.fas_user.username != comment.user.username
or comment.parent.status != "Open"
) and not flask.g.repo_committer:
- flask.abort(403, "You are not allowed to edit the comment")
+ flask.abort(403, description="You are not allowed to edit the comment")
form = pagure.forms.EditCommentForm()
@@ -910,14 +912,16 @@ def reopen_request_pull(repo, requestid, username=None, namespace=None):
if form.validate_on_submit():
if not flask.g.repo.settings.get("pull_requests", True):
- flask.abort(404, "No pull-requests found for this project")
+ flask.abort(
+ 404, description="No pull-requests found for this project"
+ )
request = pagure.lib.query.search_pull_requests(
flask.g.session, project_id=flask.g.repo.id, requestid=requestid
)
if not request:
- flask.abort(404, "Pull-request not found")
+ flask.abort(404, description="Pull-request not found")
if (
not flask.g.repo_committer
@@ -925,7 +929,8 @@ def reopen_request_pull(repo, requestid, username=None, namespace=None):
):
flask.abort(
403,
- "You are not allowed to reopen pull-request for this project",
+ description="You are not allowed to reopen pull-request "
+ "for this project",
)
try:
@@ -1000,7 +1005,7 @@ def ci_trigger_request_pull(repo, requestid, username=None, namespace=None):
)
if not request:
- flask.abort(404, "Pull-request not found")
+ flask.abort(404, description="Pull-request not found")
trigger_ci = pagure_config["TRIGGER_CI"]
if isinstance(trigger_ci, dict):
@@ -1069,18 +1074,20 @@ def merge_request_pull(repo, requestid, username=None, namespace=None):
)
if not repo.settings.get("pull_requests", True):
- flask.abort(404, "No pull-requests found for this project")
+ flask.abort(404, description="No pull-requests found for this project")
request = pagure.lib.query.search_pull_requests(
flask.g.session, project_id=repo.id, requestid=requestid
)
if not request:
- flask.abort(404, "Pull-request not found")
+ flask.abort(404, description="Pull-request not found")
if not flask.g.repo_committer:
flask.abort(
- 403, "You are not allowed to merge pull-request for this project"
+ 403,
+ description="You are not allowed to merge pull-request "
+ "for this project",
)
if repo.settings.get("Only_assignee_can_merge_pull-request", False):
@@ -1274,14 +1281,16 @@ def close_request_pull(repo, requestid, username=None, namespace=None):
if form.validate_on_submit():
if not flask.g.repo.settings.get("pull_requests", True):
- flask.abort(404, "No pull-requests found for this project")
+ flask.abort(
+ 404, description="No pull-requests found for this project"
+ )
request = pagure.lib.query.search_pull_requests(
flask.g.session, project_id=flask.g.repo.id, requestid=requestid
)
if not request:
- flask.abort(404, "Pull-request not found")
+ flask.abort(404, description="Pull-request not found")
if (
not flask.g.repo_committer
@@ -1289,7 +1298,8 @@ def close_request_pull(repo, requestid, username=None, namespace=None):
):
flask.abort(
403,
- "You are not allowed to close pull-request for this project",
+ description="You are not allowed to close pull-request "
+ "for this project",
)
pagure.lib.query.close_pull_request(
@@ -1340,21 +1350,24 @@ def refresh_request_pull(repo, requestid, username=None, namespace=None):
if form.validate_on_submit():
if not flask.g.repo.settings.get("pull_requests", True):
- flask.abort(404, "No pull-requests found for this project")
+ flask.abort(
+ 404, description="No pull-requests found for this project"
+ )
request = pagure.lib.query.search_pull_requests(
flask.g.session, project_id=flask.g.repo.id, requestid=requestid
)
if not request:
- flask.abort(404, "Pull-request not found")
+ flask.abort(404, description="Pull-request not found")
if (
not flask.g.repo_committer
and not flask.g.fas_user.username == request.user.username
):
flask.abort(
- 403, "You are not allowed to refresh this pull request"
+ 403,
+ description="You are not allowed to refresh this pull request",
)
task = pagure.lib.tasks.refresh_remote_pr.delay(
@@ -1402,20 +1415,22 @@ def update_pull_requests(repo, requestid, username=None, namespace=None):
repo = flask.g.repo
if not repo.settings.get("pull_requests", True):
- flask.abort(404, "No pull-request allowed on this project")
+ flask.abort(404, description="No pull-request allowed on this project")
request = pagure.lib.query.search_pull_requests(
flask.g.session, project_id=repo.id, requestid=requestid
)
if not request:
- flask.abort(404, "Pull-request not found")
+ flask.abort(404, description="Pull-request not found")
if (
not flask.g.repo_user
and flask.g.fas_user.username != request.user.username
):
- flask.abort(403, "You are not allowed to update this pull-request")
+ flask.abort(
+ 403, description="You are not allowed to update this pull-request"
+ )
form = pagure.forms.ConfirmationForm()
if form.validate_on_submit():
@@ -1627,15 +1642,17 @@ def new_request_pull(
if parent.url_path not in family:
flask.abort(
400,
- "%s is not part of %s's family"
+ description="%s is not part of %s's family"
% (project_to, repo.url_path),
)
orig_repo = pygit2.Repository(parent.repopath("main"))
else:
- flask.abort(404, "No project found for %s" % project_to)
+ flask.abort(
+ 404, description="No project found for %s" % project_to
+ )
if not parent.settings.get("pull_requests", True):
- flask.abort(404, "No pull-request allowed on this project")
+ flask.abort(404, description="No pull-request allowed on this project")
if parent.settings.get(
"Enforce_signed-off_commits_in_pull-request", False
@@ -1650,7 +1667,7 @@ def new_request_pull(
repo_obj, orig_repo, branch_from, branch_to
)
except pagure.exceptions.PagureException as err:
- flask.abort(400, str(err))
+ flask.abort(400, description=str(err))
repo_committer = flask.g.repo_committer
@@ -1798,10 +1815,12 @@ def new_remote_request_pull(repo, username=None, namespace=None):
repo = flask.g.repo
if pagure_config.get("DISABLE_REMOTE_PR", True):
- flask.abort(404, "Remote pull-requests disabled on this server")
+ flask.abort(
+ 404, description="Remote pull-requests disabled on this server"
+ )
if not repo.settings.get("pull_requests", True):
- flask.abort(404, "No pull-request allowed on this project")
+ flask.abort(404, description="No pull-request allowed on this project")
if repo.settings.get("Enforce_signed-off_commits_in_pull-request", False):
flask.flash(
@@ -1829,7 +1848,7 @@ def new_remote_request_pull(repo, username=None, namespace=None):
try:
result.get(timeout=0)
except Exception as err:
- flask.abort(500, err)
+ flask.abort(500, description=err)
branch_from = form.branch_from.data.strip()
branch_to = form.branch_to.data.strip()
@@ -2091,28 +2110,28 @@ def pull_request_comment_add_reaction(
form = pagure.forms.ConfirmationForm()
if not form.validate_on_submit():
- flask.abort(400, "CSRF token not valid")
+ flask.abort(400, description="CSRF token not valid")
request = pagure.lib.query.search_pull_requests(
flask.g.session, requestid=requestid, project_id=repo.id
)
if not request:
- flask.abort(404, "Comment not found")
+ flask.abort(404, description="Comment not found")
comment = pagure.lib.query.get_request_comment(
flask.g.session, request.uid, commentid
)
if "reaction" not in flask.request.form:
- flask.abort(400, "Reaction not found")
+ flask.abort(400, description="Reaction not found")
reactions = comment.reactions
r = flask.request.form["reaction"]
if not r:
- flask.abort(400, "Empty reaction is not acceptable")
+ flask.abort(400, description="Empty reaction is not acceptable")
if flask.g.fas_user.username in reactions.get(r, []):
- flask.abort(409, "Already posted this one")
+ flask.abort(409, description="Already posted this one")
reactions.setdefault(r, []).append(flask.g.fas_user.username)
comment.reactions = reactions
diff --git a/pagure/ui/groups.py b/pagure/ui/groups.py
index b845c23..b070e2e 100644
--- a/pagure/ui/groups.py
+++ b/pagure/ui/groups.py
@@ -70,7 +70,7 @@ def view_group(group):
)
if not group:
- flask.abort(404, "Group not found")
+ flask.abort(404, description="Group not found")
# Add new user to the group if asked
form = pagure.forms.AddUserToGroupForm()
@@ -141,7 +141,7 @@ def edit_group(group):
)
if not group:
- flask.abort(404, "Group not found")
+ flask.abort(404, description="Group not found")
# Edit group info
form = pagure.forms.EditGroupForm()
@@ -196,10 +196,12 @@ def give_group(group):
)
if not group:
- flask.abort(404, "Group not found")
+ flask.abort(404, description="Group not found")
if group.creator.user != flask.g.fas_user.username and not flask.g.admin:
- flask.abort(403, "You are not allowed to give away this group")
+ flask.abort(
+ 403, description="You are not allowed to give away this group"
+ )
# Give away group
form = pagure.forms.ConfirmationForm()
@@ -327,7 +329,7 @@ def group_delete(group):
flask.g.session, username=flask.g.fas_user.username
)
if not user:
- flask.abort(404, "User not found")
+ flask.abort(404, description="User not found")
if group not in user.groups:
flask.flash(
diff --git a/pagure/ui/issues.py b/pagure/ui/issues.py
index 2edeca6..673a8e6 100644
--- a/pagure/ui/issues.py
+++ b/pagure/ui/issues.py
@@ -99,7 +99,7 @@ def update_issue(repo, issueid, username=None, namespace=None):
)
if issue is None or issue.project != repo:
- flask.abort(404, "Issue not found")
+ flask.abort(404, description="Issue not found")
if (
issue.private
@@ -110,7 +110,9 @@ def update_issue(repo, issueid, username=None, namespace=None):
)
):
flask.abort(
- 403, "This issue is private and you are not allowed to view it"
+ 403,
+ description="This issue is private and you are not allowed "
+ "to view it",
)
if flask.request.form.get("edit_comment"):
@@ -141,15 +143,15 @@ def update_issue(repo, issueid, username=None, namespace=None):
flask.g.session, issue.uid, commentid
)
if comment is None or comment.issue.project != repo:
- flask.abort(404, "Comment not found")
+ flask.abort(404, description="Comment not found")
if (
not is_author or comment.parent.status != "Open"
) and not flask.g.repo_committer:
flask.abort(
403,
- "You are not allowed to remove this comment from "
- "this issue",
+ description="You are not allowed to remove this "
+ "comment from this issue",
)
issue.last_updated = datetime.datetime.utcnow()
@@ -295,7 +297,7 @@ def update_issue(repo, issueid, username=None, namespace=None):
if not urlpattern.match(link):
flask.abort(
400,
- 'Meta-data "link" field '
+ description='Meta-data "link" field '
"(%s) has invalid url (%s) "
% (key.name, link),
)
@@ -428,11 +430,11 @@ def issue_comment_add_reaction(
)
if not issue or issue.project != repo:
- flask.abort(404, "Comment not found")
+ flask.abort(404, description="Comment not found")
form = pagure.forms.ConfirmationForm()
if not form.validate_on_submit():
- flask.abort(400, "CSRF token not valid")
+ flask.abort(400, description="CSRF token not valid")
if (
issue.private
@@ -442,21 +444,21 @@ def issue_comment_add_reaction(
or not issue.user.user == flask.g.fas_user.username
)
):
- flask.abort(404, "No such issue")
+ flask.abort(404, description="No such issue")
comment = pagure.lib.query.get_issue_comment(
flask.g.session, issue.uid, commentid
)
if "reaction" not in flask.request.form:
- flask.abort(400, "Reaction not found")
+ flask.abort(400, description="Reaction not found")
reactions = comment.reactions
r = flask.request.form["reaction"]
if not r:
- flask.abort(400, "Empty reaction is not acceptable")
+ flask.abort(400, description="Empty reaction is not acceptable")
if flask.g.fas_user.username in reactions.get(r, []):
- flask.abort(409, "Already posted this one")
+ flask.abort(409, description="Already posted this one")
reactions.setdefault(r, []).append(flask.g.fas_user.username)
comment.reactions = reactions
@@ -576,7 +578,7 @@ def view_issues(repo, username=None, namespace=None):
if status is not None:
if status.lower() not in ["open", "closed", "true"]:
if status.lower() not in (s.lower() for s in repo.close_status):
- flask.abort(404, "No status of that name")
+ flask.abort(404, description="No status of that name")
status = status.capitalize()
status_count = "Closed"
other_status_count = "Open"
@@ -902,7 +904,7 @@ def new_issue(repo, username=None, namespace=None):
except pagure.exceptions.PagureException:
flask.abort(
404,
- "No such user found in the database: %s"
+ description="No such user found in the database: %s"
% (flask.g.fas_user.username),
)
@@ -1072,7 +1074,7 @@ def view_issue(repo, issueid, username=None, namespace=None):
)
if issue is None or issue.project != repo:
- flask.abort(404, "Issue not found")
+ flask.abort(404, description="Issue not found")
if issue.private:
assignee = issue.assignee.user if issue.assignee else None
@@ -1081,7 +1083,7 @@ def view_issue(repo, issueid, username=None, namespace=None):
and issue.user.user != flask.g.fas_user.username
and assignee != flask.g.fas_user.username
):
- flask.abort(404, "Issue not found")
+ flask.abort(404, description="Issue not found")
status = pagure.lib.query.get_issue_statuses(flask.g.session)
milestones = []
@@ -1149,11 +1151,13 @@ def delete_issue(repo, issueid, username=None, namespace=None):
)
if issue is None or issue.project != repo:
- flask.abort(404, "Issue not found")
+ flask.abort(404, description="Issue not found")
if not flask.g.repo_committer:
flask.abort(
- 403, "You are not allowed to remove tickets of this project"
+ 403,
+ description="You are not allowed to remove tickets of "
+ "this project",
)
form = pagure.forms.ConfirmationForm()
@@ -1223,13 +1227,16 @@ def edit_issue(repo, issueid, username=None, namespace=None):
)
if issue is None or issue.project != repo:
- flask.abort(404, "Issue not found")
+ flask.abort(404, description="Issue not found")
if not (
flask.g.repo_committer
or flask.g.fas_user.username == issue.user.username
):
- flask.abort(403, "You are not allowed to edit issues for this project")
+ flask.abort(
+ 403,
+ description="You are not allowed to edit issues for this project",
+ )
status = pagure.lib.query.get_issue_statuses(flask.g.session)
form = pagure.forms.IssueForm(status=status)
@@ -1246,7 +1253,7 @@ def edit_issue(repo, issueid, username=None, namespace=None):
except pagure.exceptions.PagureException:
flask.abort(
404,
- "No such user found in the database: %s"
+ description="No such user found in the database: %s"
% (flask.g.fas_user.username),
)
@@ -1357,7 +1364,7 @@ def upload_issue(repo, issueid, username=None, namespace=None):
)
if issue is None or issue.project != repo:
- flask.abort(404, "Issue not found")
+ flask.abort(404, description="Issue not found")
try:
user_obj = pagure.lib.query.get_user(
@@ -1366,7 +1373,7 @@ def upload_issue(repo, issueid, username=None, namespace=None):
except pagure.exceptions.PagureException:
flask.abort(
404,
- "No such user found in the database: %s"
+ description="No such user found in the database: %s"
% (flask.g.fas_user.username),
)
@@ -1433,7 +1440,7 @@ def view_issue_raw_file(repo, filename=None, username=None, namespace=None):
repo_obj = pygit2.Repository(reponame)
if repo_obj.is_empty:
- flask.abort(404, "Empty repo cannot have a file")
+ flask.abort(404, description="Empty repo cannot have a file")
branch = repo_obj.lookup_branch("master")
commit = branch.peel()
@@ -1442,12 +1449,12 @@ def view_issue_raw_file(repo, filename=None, username=None, namespace=None):
repo_obj, commit.tree, ["files", filename], bail_on_tree=True
)
if not content or isinstance(content, pygit2.Tree):
- flask.abort(404, "File not found")
+ flask.abort(404, description="File not found")
data = repo_obj[content.oid].data
if not data:
- flask.abort(404, "No content found")
+ flask.abort(404, description="No content found")
_log.info(
"Migrating file %s for project %s to attachments",
@@ -1516,20 +1523,22 @@ def edit_comment_issue(
)
if issue is None or issue.project != project:
- flask.abort(404, "Issue not found")
+ flask.abort(404, description="Issue not found")
comment = pagure.lib.query.get_issue_comment(
flask.g.session, issue.uid, commentid
)
if comment is None or comment.parent.project != project:
- flask.abort(404, "Comment not found")
+ flask.abort(404, description="Comment not found")
if (
flask.g.fas_user.username != comment.user.username
or comment.parent.status != "Open"
) and not flask.g.repo_user:
- flask.abort(403, "You are not allowed to edit this comment")
+ flask.abort(
+ 403, description="You are not allowed to edit this comment"
+ )
form = pagure.forms.EditCommentForm()
@@ -1631,7 +1640,7 @@ def view_report(repo, report, username=None, namespace=None):
"""
reports = flask.g.repo.reports
if report not in reports:
- flask.abort(404, "No such report found")
+ flask.abort(404, description="No such report found")
flask.request.args = werkzeug.datastructures.ImmutableMultiDict(
reports[report]
diff --git a/pagure/ui/login.py b/pagure/ui/login.py
index e70ba42..8383603 100644
--- a/pagure/ui/login.py
+++ b/pagure/ui/login.py
@@ -303,7 +303,7 @@ def change_password():
)
if not user_obj:
- flask.abort(404, "User not found")
+ flask.abort(404, description="User not found")
if form.validate_on_submit():
diff --git a/pagure/ui/plugins.py b/pagure/ui/plugins.py
index feed3d3..5238051 100644
--- a/pagure/ui/plugins.py
+++ b/pagure/ui/plugins.py
@@ -86,13 +86,13 @@ def view_plugin(repo, plugin, username=None, namespace=None, full=True):
# enables us to keep the repos totally discreate and prevents from leaking
# information outside
if repo.private and plugin == "Pagure CI":
- flask.abort(404, "Plugin disabled")
+ flask.abort(404, description="Plugin disabled")
if plugin in pagure.config.config.get("DISABLED_PLUGINS", []):
- flask.abort(404, "Plugin disabled")
+ flask.abort(404, description="Plugin disabled")
if plugin == "default":
- flask.abort(403, "This plugin cannot be changed")
+ flask.abort(403, description="This plugin cannot be changed")
plugin = pagure.lib.plugins.get_plugin(plugin)
fields = []
@@ -161,14 +161,14 @@ def view_plugin(repo, plugin, username=None, namespace=None, full=True):
except FileNotFoundException as err:
flask.g.session.rollback()
_log.exception(err)
- flask.abort(404, "No git repo found")
+ flask.abort(404, description="No git repo found")
else:
try:
plugin.remove(repo)
except FileNotFoundException as err:
flask.g.session.rollback()
_log.exception(err)
- flask.abort(404, "No git repo found")
+ flask.abort(404, description="No git repo found")
flask.g.session.delete(dbobj)
flask.flash("Hook %s deactivated" % plugin.name)
diff --git a/pagure/ui/repo.py b/pagure/ui/repo.py
index 626674d..1236d41 100644
--- a/pagure/ui/repo.py
+++ b/pagure/ui/repo.py
@@ -201,7 +201,7 @@ def view_repo_branch(repo, branchname, username=None, namespace=None):
repo_obj = flask.g.repo_obj
if branchname not in repo_obj.listall_branches():
- flask.abort(404, 'Branch not found')
+ flask.abort(404, description='Branch not found')
branch = repo_obj.lookup_branch(branchname)
if not repo_obj.is_empty and not repo_obj.head_is_unborn:
@@ -448,9 +448,9 @@ def compare_commits(repo, commit1, commit2, username=None, namespace=None):
commit1_obj = repo_obj.get(commit1)
commit2_obj = repo_obj.get(commit2)
if commit1_obj is None:
- flask.abort(404, "First commit does not exist")
+ flask.abort(404, description="First commit does not exist")
if commit2_obj is None:
- flask.abort(404, "Last commit does not exist")
+ flask.abort(404, description="Last commit does not exist")
# Get commits diff data
diff = repo_obj.diff(commit1, commit2)
@@ -511,7 +511,7 @@ def view_file(repo, identifier, filename, username=None, namespace=None):
repo_obj = flask.g.repo_obj
if repo_obj.is_empty:
- flask.abort(404, "Empty repo cannot have a file")
+ flask.abort(404, description="Empty repo cannot have a file")
if identifier in repo_obj.listall_branches():
branchname = identifier
@@ -523,7 +523,7 @@ def view_file(repo, identifier, filename, username=None, namespace=None):
branchname = identifier
except ValueError:
if "master" not in repo_obj.listall_branches():
- flask.abort(404, "Branch not found")
+ flask.abort(404, description="Branch not found")
# If it's not a commit id then it's part of the filename
commit = repo_obj[repo_obj.head.target]
branchname = "master"
@@ -542,13 +542,13 @@ def view_file(repo, identifier, filename, username=None, namespace=None):
repo_obj, tree, filename.split("/"), bail_on_tree=True
)
if not content:
- flask.abort(404, "File not found")
+ flask.abort(404, description="File not found")
content = repo_obj[content.oid]
else:
content = commit
if not content:
- flask.abort(404, "File not found")
+ flask.abort(404, description="File not found")
readme = None
safe = False
@@ -611,7 +611,7 @@ def view_file(repo, identifier, filename, username=None, namespace=None):
else:
output_type = "binary"
elif isinstance(content, pygit2.Commit):
- flask.abort(404, "File not found")
+ flask.abort(404, description="File not found")
else:
content = sorted(content, key=lambda x: x.filemode)
for i in content:
@@ -676,7 +676,7 @@ def view_raw_file(
repo_obj = flask.g.repo_obj
if repo_obj.is_empty:
- flask.abort(404, "Empty repo cannot have a file")
+ flask.abort(404, description="Empty repo cannot have a file")
if identifier in repo_obj.listall_branches():
branch = repo_obj.lookup_branch(identifier)
@@ -686,12 +686,12 @@ def view_raw_file(
commit = repo_obj.get(identifier)
except ValueError:
if "master" not in repo_obj.listall_branches():
- flask.abort(404, "Branch not found")
+ flask.abort(404, description="Branch not found")
# If it's not a commit id then it's part of the filename
commit = repo_obj[repo_obj.head.target]
if not commit:
- flask.abort(404, "Commit %s not found" % (identifier))
+ flask.abort(404, description="Commit %s not found" % (identifier))
if isinstance(commit, pygit2.Tag):
commit = commit.peel(pygit2.Commit)
@@ -704,7 +704,7 @@ def view_raw_file(
repo_obj, commit.tree, filename.split("/"), bail_on_tree=True
)
if not content or isinstance(content, pygit2.Tree):
- flask.abort(404, "File not found")
+ flask.abort(404, description="File not found")
data = repo_obj[content.oid].data
else:
@@ -715,14 +715,14 @@ def view_raw_file(
parent = repo_obj.revparse_single("%s^" % identifier)
diff = repo_obj.diff(parent, commit)
except (KeyError, ValueError):
- flask.abort(404, "Identifier not found")
+ flask.abort(404, description="Identifier not found")
else:
# First commit in the repo
diff = commit.tree.diff_to_tree(swap=True)
data = diff.patch
if not data:
- flask.abort(404, "No content found")
+ flask.abort(404, description="No content found")
return (data, 200, pagure.lib.mimetype.get_type_headers(filename, data))
@@ -740,7 +740,7 @@ def view_blame_file(repo, filename, username=None, namespace=None):
branchname = flask.request.args.get("identifier", "master")
if repo_obj.is_empty or repo_obj.head_is_unborn:
- flask.abort(404, "Empty repo cannot have a file")
+ flask.abort(404, description="Empty repo cannot have a file")
if branchname in repo_obj.listall_branches():
branch = repo_obj.lookup_branch(branchname)
@@ -758,19 +758,19 @@ def view_blame_file(repo, filename, username=None, namespace=None):
repo_obj, commit.tree, filename.split("/"), bail_on_tree=True
)
if not content:
- flask.abort(404, "File not found")
+ flask.abort(404, description="File not found")
if not isinstance(content, pygit2.Blob):
- flask.abort(404, "File not found")
+ flask.abort(404, description="File not found")
if is_binary_string(content.data):
- flask.abort(400, "Binary files cannot be blamed")
+ flask.abort(400, description="Binary files cannot be blamed")
try:
content = encoding_utils.decode(content.data)
except pagure.exceptions.PagureException:
# We cannot decode the file, so bail but warn the admins
_log.exception("File could not be decoded")
- flask.abort(500, "File could not be decoded")
+ flask.abort(500, description="File could not be decoded")
blame = repo_obj.blame(filename, newest_commit=commit.oid.hex)
@@ -801,7 +801,7 @@ def view_commit(repo, commitid, username=None, namespace=None):
"""
repo = flask.g.repo
if not repo:
- flask.abort(404, "Project not found")
+ flask.abort(404, description="Project not found")
repo_obj = flask.g.repo_obj
@@ -820,13 +820,13 @@ def view_commit(repo, commitid, username=None, namespace=None):
try:
commit = repo_obj.get(commitid)
except ValueError:
- flask.abort(404, "Commit not found")
+ flask.abort(404, description="Commit not found")
if commit is None:
- flask.abort(404, "Commit not found")
+ flask.abort(404, description="Commit not found")
if isinstance(commit, pygit2.Blob):
- flask.abort(404, "Commit not found")
+ flask.abort(404, description="Commit not found")
if commit.parents:
diff = repo_obj.diff(commit.parents[0], commit)
@@ -899,13 +899,13 @@ def view_commit_patch_or_diff(
if is_js:
return errorresponse
else:
- flask.abort(404, "Commit not found")
+ flask.abort(404, description="Commit not found")
if commit is None:
if is_js:
return errorresponse
else:
- flask.abort(404, "Commit not found")
+ flask.abort(404, description="Commit not found")
if is_js:
patches = pagure.lib.git.commit_to_patch(
@@ -1697,7 +1697,7 @@ def new_repo_hook_token(repo, username=None, namespace=None):
form = pagure.forms.ConfirmationForm()
if not form.validate_on_submit():
- flask.abort(400, "Invalid request")
+ flask.abort(400, description="Invalid request")
try:
repo.hook_token = pagure.lib.login.id_generator(40)
@@ -1736,7 +1736,9 @@ def remove_deploykey(repo, keyid, username=None, namespace=None):
"""
if not pagure_config.get("DEPLOY_KEY", True):
- flask.abort(404, "This pagure instance disabled deploy keys")
+ flask.abort(
+ 404, description="This pagure instance disabled deploy keys"
+ )
repo = flask.g.repo
@@ -1799,7 +1801,10 @@ def remove_user(repo, userid, username=None, namespace=None):
"""
if not pagure_config.get("ENABLE_USER_MNGT", True):
- flask.abort(404, "User management not allowed in the pagure instance")
+ flask.abort(
+ 404,
+ description="User management not allowed in the pagure instance",
+ )
repo = flask.g.repo
@@ -1865,7 +1870,9 @@ def add_deploykey(repo, username=None, namespace=None):
"""
if not pagure_config.get("DEPLOY_KEY", True):
- flask.abort(404, "This pagure instance disabled deploy keys")
+ flask.abort(
+ 404, description="This pagure instance disabled deploy keys"
+ )
repo = flask.g.repo
@@ -1931,7 +1938,9 @@ def add_user(repo, username=None, namespace=None):
if not pagure_config.get("ENABLE_USER_MNGT", True):
flask.abort(
- 404, "User management is not allowed in this pagure instance"
+ 404,
+ description="User management is not allowed in this "
+ "pagure instance",
)
repo = flask.g.repo
@@ -2015,7 +2024,9 @@ def remove_group_project(repo, groupid, username=None, namespace=None):
if not pagure_config.get("ENABLE_USER_MNGT", True):
flask.abort(
- 404, "User management is not allowed in this pagure instance"
+ 404,
+ description="User management is not allowed in this "
+ "pagure instance",
)
repo = flask.g.repo
@@ -2087,7 +2098,9 @@ def add_group_project(repo, username=None, namespace=None):
if not pagure_config.get("ENABLE_USER_MNGT", True):
flask.abort(
- 404, "User management is not allowed in this pagure instance"
+ 404,
+ description="User management is not allowed in this "
+ "pagure instance",
)
repo = flask.g.repo
@@ -2171,7 +2184,10 @@ def regenerate_git(repo, username=None, namespace=None):
regenerate = flask.request.form.get("regenerate")
if not regenerate or regenerate.lower() not in ["tickets", "requests"]:
- flask.abort(400, "You can only regenerate tickest or requests repos")
+ flask.abort(
+ 400,
+ description="You can only regenerate tickest or requests repos",
+ )
form = pagure.forms.ConfirmationForm()
if form.validate_on_submit():
@@ -2246,7 +2262,9 @@ def add_token(repo, username=None, namespace=None):
if not flask.g.repo_committer:
flask.abort(
- 403, "You are not allowed to change the settings for this project"
+ 403,
+ description="You are not allowed to change the settings for "
+ "this project",
)
acls = pagure.lib.query.get_acls(
@@ -2318,7 +2336,7 @@ def renew_api_token(repo, token_id, username=None, namespace=None):
or token.project.fullname != repo.fullname
or token.user.username != flask.g.fas_user.username
):
- flask.abort(404, "Token not found")
+ flask.abort(404, description="Token not found")
form = pagure.forms.ConfirmationForm()
@@ -2384,7 +2402,7 @@ def revoke_api_token(repo, token_id, username=None, namespace=None):
or token.project.fullname != repo.fullname
or token.user.username != flask.g.fas_user.username
):
- flask.abort(404, "Token not found")
+ flask.abort(404, description="Token not found")
form = pagure.forms.ConfirmationForm()
@@ -2444,7 +2462,7 @@ def edit_file(repo, branchname, filename, username=None, namespace=None):
)
if repo_obj.is_empty:
- flask.abort(404, "Empty repo cannot have a file")
+ flask.abort(404, description="Empty repo cannot have a file")
form = pagure.forms.EditFileForm(emails=user.emails)
@@ -2453,7 +2471,7 @@ def edit_file(repo, branchname, filename, username=None, namespace=None):
branch = repo_obj.lookup_branch(branchname)
commit = branch.peel(pygit2.Commit)
else:
- flask.abort(400, "Invalid branch specified")
+ flask.abort(400, description="Invalid branch specified")
if form.validate_on_submit():
try:
@@ -2484,17 +2502,17 @@ def edit_file(repo, branchname, filename, username=None, namespace=None):
repo_obj, commit.tree, filename.split("/")
)
if not content or isinstance(content, pygit2.Tree):
- flask.abort(404, "File not found")
+ flask.abort(404, description="File not found")
if is_binary_string(content.data):
- flask.abort(400, "Cannot edit binary files")
+ flask.abort(400, description="Cannot edit binary files")
try:
data = repo_obj[content.oid].data.decode("utf-8")
except UnicodeDecodeError: # pragma: no cover
# In theory we shouldn't reach here since we check if the file
# is binary with `is_binary_string()` above
- flask.abort(400, "Cannot edit binary files")
+ flask.abort(400, description="Cannot edit binary files")
else:
data = form.content.data
@@ -2532,20 +2550,27 @@ def delete_branch(repo, branchname, username=None, namespace=None):
if not flask.g.repo.is_fork and not pagure_config.get(
"ALLOW_DELETE_BRANCH", True
):
- flask.abort(404, "This pagure instance does not allow branch deletion")
+ flask.abort(
+ 404,
+ description="This pagure instance does not allow branch deletion",
+ )
repo_obj = flask.g.repo_obj
if not flask.g.repo_committer:
flask.abort(
- 403, "You are not allowed to delete branch for this project"
+ 403,
+ description="You are not allowed to delete branch for "
+ "this project",
)
if branchname == "master":
- flask.abort(403, "You are not allowed to delete the master branch")
+ flask.abort(
+ 403, description="You are not allowed to delete the master branch"
+ )
if branchname not in repo_obj.listall_branches():
- flask.abort(404, "Branch not found")
+ flask.abort(404, description="Branch not found")
task = pagure.lib.tasks.delete_branch.delay(
repo, namespace, username, branchname
@@ -2567,7 +2592,7 @@ def view_docs(repo, username=None, filename=None, namespace=None):
repo = flask.g.repo
if not pagure_config.get("DOC_APP_URL"):
- flask.abort(404, "This pagure instance has no doc server")
+ flask.abort(404, description="This pagure instance has no doc server")
return flask.render_template(
"docs.html",
@@ -2813,7 +2838,9 @@ def update_quick_replies(repo, username=None, namespace=None):
repo = flask.g.repo
if not repo.settings.get("pull_requests", True):
- flask.abort(404, "Pull requests are disabled for this project")
+ flask.abort(
+ 404, description="Pull requests are disabled for this project"
+ )
form = pagure.forms.ConfirmationForm()
@@ -2969,21 +2996,25 @@ def move_to_repospanner(repo, username=None, namespace=None):
if not pagure.utils.is_admin():
flask.abort(
- 403, "You are not allowed to transfer this project to repoSpanner"
+ 403,
+ description="You are not allowed to transfer this project "
+ "to repoSpanner",
)
if not pagure_config.get("REPOSPANNER_ADMIN_MIGRATION"):
- flask.abort(403, "It is not allowed to request migration of a repo")
+ flask.abort(
+ 403, description="It is not allowed to request migration of a repo"
+ )
form = pagure.forms.ConfirmationForm()
if form.validate_on_submit():
region = flask.request.form.get("region", "").strip()
if not region:
- flask.abort(404, "No target region specified")
+ flask.abort(404, description="No target region specified")
if region not in pagure_config.get("REPOSPANNER_REGIONS"):
- flask.abort(404, "Invalid region specified")
+ flask.abort(404, description="Invalid region specified")
_log.info(
"Repo %s requested to be migrated to repoSpanner region %s",
@@ -3034,19 +3065,23 @@ def give_project(repo, username=None, namespace=None):
flask.g.fas_user.username != repo.user.user
and not pagure.utils.is_admin()
):
- flask.abort(403, "You are not allowed to give this project")
+ flask.abort(
+ 403, description="You are not allowed to give this project"
+ )
form = pagure.forms.ConfirmationForm()
if form.validate_on_submit():
new_username = flask.request.form.get("user", "").strip()
if not new_username:
- flask.abort(404, "No user specified")
+ flask.abort(404, description="No user specified")
new_owner = pagure.lib.query.search_user(
flask.g.session, username=new_username
)
if not new_owner:
- flask.abort(404, "No such user %s found" % new_username)
+ flask.abort(
+ 404, description="No such user %s found" % new_username
+ )
try:
old_main_admin = repo.user.user
pagure.lib.query.set_project_owner(
@@ -3106,7 +3141,7 @@ def project_dowait(repo, username=None, namespace=None):
should only ever be done in test instances.
"""
if not pagure_config.get("ALLOW_PROJECT_DOWAIT", False):
- flask.abort(401, "No")
+ flask.abort(401, description="No")
task = pagure.lib.tasks.project_dowait.delay(
name=repo, namespace=namespace, user=username
@@ -3301,12 +3336,12 @@ def edit_tag(repo, tag, username=None, namespace=None):
tags = pagure.lib.query.get_tags_of_project(flask.g.session, repo)
if not tags:
- flask.abort(404, "Project has no tags to edit")
+ flask.abort(404, description="Project has no tags to edit")
# Check the tag exists, and get its old/original color
tagobj = pagure.lib.query.get_colored_tag(flask.g.session, tag, repo.id)
if not tagobj:
- flask.abort(404, "Tag %s not found in this project" % tag)
+ flask.abort(404, description="Tag %s not found in this project" % tag)
form = pagure.forms.AddIssueTagForm()
if form.validate_on_submit():
@@ -3421,16 +3456,20 @@ def generate_project_archive(
_log.debug("No ARCHIVE_FOLDER specified in the configuration")
flask.abort(
404,
- "This pagure instance isn't configured to support this feature",
+ description="This pagure instance isn't configured to support "
+ "this feature",
)
if not os.path.exists(archive_folder):
_log.debug("No ARCHIVE_FOLDER could not be found on disk")
- flask.abort(500, "Incorrect configuration, please contact your admin")
+ flask.abort(
+ 500,
+ description="Incorrect configuration, please contact your admin",
+ )
extensions = ["tar.gz", "tar", "zip"]
if extension not in extensions:
_log.debug("%s no in %s", extension, extensions)
- flask.abort(400, "Invalid archive format specified")
+ flask.abort(400, description="Invalid archive format specified")
name = werkzeug.secure_filename(name)
@@ -3449,15 +3488,15 @@ def generate_project_archive(
commit = tag
else:
_log.debug("Found %s instead of a tag", tag)
- flask.abort(400, "Invalid reference provided")
+ flask.abort(400, description="Invalid reference provided")
else:
try:
commit = repo_obj.get(ref)
except ValueError:
- flask.abort(404, "Invalid commit provided")
+ flask.abort(404, description="Invalid commit provided")
if not isinstance(commit, pygit2.Commit):
- flask.abort(400, "Invalid reference specified")
+ flask.abort(400, description="Invalid reference specified")
tag_path = ""
tag_filename = None
diff --git a/pagure/utils.py b/pagure/utils.py
index 5637bcd..8f3991c 100644
--- a/pagure/utils.py
+++ b/pagure/utils.py
@@ -581,7 +581,7 @@ def get_repo_path(repo):
"""
repopath = repo.repopath("main")
if not os.path.exists(repopath):
- flask.abort(404, "No git repo found")
+ flask.abort(404, description="No git repo found")
return repopath
diff --git a/tests/test_pagure_flask_ui_app.py b/tests/test_pagure_flask_ui_app.py
index 3cb913d..98207b5 100644
--- a/tests/test_pagure_flask_ui_app.py
+++ b/tests/test_pagure_flask_ui_app.py
@@ -272,8 +272,11 @@ class PagureFlaskApptests(tests.Modeltests):
output_text = output.get_data(as_text=True)
self.assertIn(
'Overview - project+1 - Pagure', output_text)
- self.assertIn(
- 'project+1',
+ self.assertTrue(
+ 'project+1' in
+ output_text
+ or
+ 'project+1' in
output_text
)