From a26bca9638a5fe77f5e833738386e6805a177744 Mon Sep 17 00:00:00 2001 From: Evgeny Fadeev Date: Mon, 6 May 2013 20:54:07 -0400 Subject: restricted comment edits only to post owners and mods/admins --- askbot/media/js/post.js | 8 ++++++-- askbot/templates/question.html | 11 +++++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/askbot/media/js/post.js b/askbot/media/js/post.js index 4a2fb0d6..7f9e3d42 100644 --- a/askbot/media/js/post.js +++ b/askbot/media/js/post.js @@ -2225,8 +2225,12 @@ Comment.prototype.loadText = function(on_load_handler){ url: askbot['urls']['getComment'], data: {id: this._data['id']}, success: function(json){ - me._data['text'] = json['text']; - on_load_handler() + if (json['success']) { + me._data['text'] = json['text']; + on_load_handler() + } else { + showMessage(me.getElement(), json['message'], 'after'); + } }, error: function(xhr, textStatus, exception) { showMessage(me.getElement(), xhr.responseText, 'after'); diff --git a/askbot/templates/question.html b/askbot/templates/question.html index 3364cc2f..9a508a2f 100644 --- a/askbot/templates/question.html +++ b/askbot/templates/question.html @@ -62,6 +62,13 @@ return null; }; + var postIsComment = function(postId) { + if (document.getElementById('comment-' + postId)) { + return true; + } + return false; + }; + var removeNode = function(node) { node.parentNode.removeChild(node); }; @@ -186,9 +193,9 @@ ) { removeNode(closeBtn[0]); } + var repLow = (data['userReputation'] < {{settings.MIN_REP_TO_EDIT_OTHERS_POSTS}}); if (//maybe remove "edit" button - data['userReputation'] < - {{settings.MIN_REP_TO_EDIT_OTHERS_POSTS}} + repLow || postIsComment(post_id)//only authors edit comments ){ var edit_btn = document.getElementById( 'post-' + post_id + '-edit' -- cgit v1.2.3-1-g7c22