From cbd16782b78cf58e01ee8818e26a994a338b8097 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jun 05 2015 14:56:31 +0000 Subject: [PATCH 1/4] Fix who is allowed to drop comments You are now allowed to drop a comment if: - You did not make the comment or - The PR/Issue is Closed and - You are not a project admin --- diff --git a/pagure/ui/fork.py b/pagure/ui/fork.py index cb81346..57de775 100644 --- a/pagure/ui/fork.py +++ b/pagure/ui/fork.py @@ -353,8 +353,8 @@ def pull_request_drop_comment(repo, requestid, username=None): flask.abort(404, 'Comment not found') if (flask.g.fas_user.username != comment.user.username - and comment.parent.status is True) \ - or not is_repo_admin(repo): + or comment.parent.status is False) \ + and not is_repo_admin(repo): flask.abort( 403, 'You are not allowed to remove this comment from ' diff --git a/pagure/ui/issues.py b/pagure/ui/issues.py index 8184343..bd80924 100644 --- a/pagure/ui/issues.py +++ b/pagure/ui/issues.py @@ -77,8 +77,8 @@ def update_issue(repo, issueid, username=None): flask.abort(404, 'Comment not found') if (flask.g.fas_user.username != comment.user.username - and comment.parent.status is True) \ - or not is_repo_admin(repo): + or comment.parent.status != 'Open') \ + and not is_repo_admin(repo): flask.abort( 403, 'You are not allowed to remove this comment from ' From 34464ab11a9c060a8cd7582431f3c63c6e737f8b Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jun 05 2015 14:57:55 +0000 Subject: [PATCH 2/4] Fix showing the drop comment button on comments The status must be 'Open' for issues and True for pull-requests --- diff --git a/pagure/templates/_formhelper.html b/pagure/templates/_formhelper.html index d05ce61..d9c46f7 100644 --- a/pagure/templates/_formhelper.html +++ b/pagure/templates/_formhelper.html @@ -76,7 +76,7 @@ reply {% if id != 0 and g.fas_user and ( - (comment.parent.status == True and g.fas_user.username == comment.user.username) + (comment.parent.status in [True, 'Open'] and g.fas_user.username == comment.user.username) or repo_admin) %}