From a42bf9bb7656dd87ae75872d37f39406b60c383a Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Feb 03 2016 10:04:14 +0000 Subject: Do not show the edit and delete buttons to everyone Only the user who made the comment should see these buttons, it could also be the admins but for now they will have to reload the page. --- diff --git a/pagure/static/issue_ev.js b/pagure/static/issue_ev.js index 3d8048b..52fcefe 100644 --- a/pagure/static/issue_ev.js +++ b/pagure/static/issue_ev.js @@ -118,7 +118,7 @@ remove_deps = function(data, issue_uid, _issue_url) { selectize.removeItem(dep); } -add_comment = function(data) { +add_comment = function(data, username) { console.log('Adding comment ' + data.comment_added); var field = $('#comments'); var _data = '
\ @@ -144,8 +144,9 @@ add_comment = function(data) { \
\ '; + field.html(field.html() + _data); } @@ -241,7 +244,7 @@ private_issue_update = function(data, _api_issue_url, issue_uid) { } process_event = function( - data, issue_uid, _issue_url, _issues_url, _api_issue_url) + data, issue_uid, _issue_url, _issues_url, _api_issue_url, username) { console.log(data); var category = null; @@ -279,7 +282,7 @@ process_event = function( category = 'Dependency removed'; } else if (data.comment_added){ - add_comment(data); + add_comment(data, username); category = 'Comment added'; } else if (data.comment_updated){ diff --git a/pagure/static/request_ev.js b/pagure/static/request_ev.js index 2fbcc1e..ada210d 100644 --- a/pagure/static/request_ev.js +++ b/pagure/static/request_ev.js @@ -1,9 +1,9 @@ -add_comment = function(data) { +add_comment = function(data, username) { console.log('Adding comment ' + data.comment_added); var field = $('#comments'); - var edit_btn = ' \ \ '; @@ -35,14 +35,16 @@ add_comment = function(data) {
\ \ \ - ' - + edit_btn + + '; + if ( data.comment_user == username) { + _data += edit_btn + ' \ -
\ + '; + } + _data += ' \ \ \ '; @@ -70,14 +72,16 @@ add_comment = function(data) {
\ \ \ - ' - + edit_btn - + ' \ -
\ + '; + } + _data += ' \ \ '; } @@ -113,12 +117,12 @@ update_comment = function(data) { field.find('.issue_comment').show(); } -process_event = function(data, requestid){ +process_event = function(data, requestid, username){ console.log(data); var category = null; var originalTitle = document.title; if (data.comment_added){ - add_comment(data); + add_comment(data, username); category = 'comment'; } else if (data.comment_updated){ update_comment(data); diff --git a/pagure/templates/issue.html b/pagure/templates/issue.html index 67af0db..de2c328 100644 --- a/pagure/templates/issue.html +++ b/pagure/templates/issue.html @@ -354,7 +354,8 @@ source.addEventListener('message', function(e) { url_for('view_issue', username=username, repo=repo.name, issueid='-123456789')}}'; process_event(data, "{{ issue.uid }}", _issue_url, - _issues_url, _api_issues_url); + _issues_url, _api_issues_url, + "{{ g.fas_user.username }}"); setup_edit_btns(); setup_reply_btns(); diff --git a/pagure/templates/pull_request.html b/pagure/templates/pull_request.html index 53789b9..25e9a4b 100644 --- a/pagure/templates/pull_request.html +++ b/pagure/templates/pull_request.html @@ -902,7 +902,7 @@ window.onbeforeunload = function() { source.addEventListener('message', function(e) { console.log(e.data); var data = $.parseJSON(e.data); - process_event(data, "{{ request.uid }}"); + process_event(data, "{{ request.uid }}", "{{ g.fas_user.username }}"); setup_edit_btns(); setup_reply_btns(); }, false);