From ae92283730f6f242cb0e71dedd7a44b58ccaf566 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Feb 09 2018 09:38:58 +0000 Subject: Fix editing and deleting comments added by the EV server to PRs Basically, we had the project url hard-coded in the html instead of have it automatically generated from the content passed on by the EV server so editing a comment added by the EV server was only ever going to work on a one project. In addition, the form and csrf token were missing to allow the delete button to work. Both form and csrf token are now present on the html page, thus allowing to right away delete a generic comment that was added by the EV server. Fixes https://pagure.io/pagure/issue/2958 Signed-off-by: Pierre-Yves Chibon --- diff --git a/pagure/lib/__init__.py b/pagure/lib/__init__.py index 29d1841..1bfda0a 100644 --- a/pagure/lib/__init__.py +++ b/pagure/lib/__init__.py @@ -1238,6 +1238,7 @@ def add_pull_request_comment(session, request, commit, tree_id, filename, 'comment_added': comment_text, 'comment_user': pr_comment.user.user, 'comment_id': pr_comment.id, + 'project': request.project.fullname, 'avatar_url': avatar_url_from_email( pr_comment.user.default_email, size=16), 'comment_date': pr_comment.date_created.strftime( diff --git a/pagure/static/request_ev.js b/pagure/static/request_ev.js index 66d36ba..58219c5 100644 --- a/pagure/static/request_ev.js +++ b/pagure/static/request_ev.js @@ -2,7 +2,7 @@ add_comment = function(data, username) { console.log('Adding comment ' + data.comment_added); var field = $('#comments'); var edit_btn = ' \ \ @@ -61,41 +61,46 @@ add_comment = function(data, username) { \ '; } else { - var _data = '
\ - \ -
\ -
\ -
\ - \ - ' - + emojione.toImage(data.comment_added) + '\ -
\ -
\ -
\ -
\ -
\ - \ - \ - '; - if ( data.comment_user == username) { - _data += edit_btn + - ''; - } - _data += '
\ -
\ -
'; + var _csrf = $('#csrf_token').clone(); + var _data = '
\ +
\ + \ +
\ +
\ +
\ + \ + ' + + emojione.toImage(data.comment_added) + '\ +
\ +
\ +
\ +
\ +
\ + \ + \ + '; + if ( data.comment_user == username) { + _data += edit_btn + + ''; + } + _data += '
\ +
\ +
\ + \ + '; } if (inline){