diff options
author | Evgeny Fadeev <evgeny.fadeev@gmail.com> | 2013-04-10 23:53:07 -0400 |
---|---|---|
committer | Evgeny Fadeev <evgeny.fadeev@gmail.com> | 2013-04-10 23:53:07 -0400 |
commit | 7377d4b06d4f5c6ce7823ee016e26b4718a8b2a3 (patch) | |
tree | 835c688adff72035e022e086dd06729b7c5bf6e8 /askbot/templates | |
parent | 0dbfd025feeb018c8d82889801c4c195a4be8a92 (diff) | |
download | askbot-7377d4b06d4f5c6ce7823ee016e26b4718a8b2a3.tar.gz askbot-7377d4b06d4f5c6ce7823ee016e26b4718a8b2a3.tar.bz2 askbot-7377d4b06d4f5c6ce7823ee016e26b4718a8b2a3.zip |
removed reputation limit to post comments and allowed users repost own answers and comments
Diffstat (limited to 'askbot/templates')
-rw-r--r-- | askbot/templates/faq_static.html | 2 | ||||
-rw-r--r-- | askbot/templates/macros.html | 6 | ||||
-rw-r--r-- | askbot/templates/question.html | 53 |
3 files changed, 53 insertions, 8 deletions
diff --git a/askbot/templates/faq_static.html b/askbot/templates/faq_static.html index 0bc05cc8..3a2638be 100644 --- a/askbot/templates/faq_static.html +++ b/askbot/templates/faq_static.html @@ -31,10 +31,12 @@ <td class="faq-rep-item"><strong>{{settings.MIN_REP_TO_VOTE_UP}}</strong></td> <td>{% trans %}upvote{% endtrans %}</td> </tr> + {# <tr> <td class="faq-rep-item"><strong>{{settings.MIN_REP_TO_LEAVE_COMMENTS}}</strong></td> <td>{% trans %}add comments{% endtrans %}</td> </tr> + #} <tr> <td class="faq-rep-item"><strong>{{settings.MIN_REP_TO_VOTE_DOWN}}</strong></td> <td>{% trans %}downvote{% endtrans %}</td> diff --git a/askbot/templates/macros.html b/askbot/templates/macros.html index 2d345940..74fc37ce 100644 --- a/askbot/templates/macros.html +++ b/askbot/templates/macros.html @@ -378,6 +378,12 @@ for the purposes of the AJAX comment editor #} </script> {%- endmacro -%} +{%- macro csrf_middleware_token(csrf_token) -%} + <div style="display: none;"> + <input type="hidden" name="csrfmiddlewaretoken" value="{{ csrf_token }}" /> + </div> +{%- endmacro -%} + {%- macro post_comments_widget( post=None, show_post = None, diff --git a/askbot/templates/question.html b/askbot/templates/question.html index c11fba04..6235f7ed 100644 --- a/askbot/templates/question.html +++ b/askbot/templates/question.html @@ -43,6 +43,25 @@ return nodes; }; + var hasAttribute = function(node, attrName) { + if (node.hasAttribute) { + return node.hasAttribute(attrName); + } else { + return (!(!(node.getAttribute(attrName)))); + } + }; + + var findChildByAttribute = function(node, attrName, attrVal) { + var children = node.childNodes; + for (var i = 0; i < children.length; i++) { + var child = children[i]; + if (child.getAttribute(attrName) === attrVal) { + return child; + } + }; + return null; + }; + var removeNode = function(node) { node.parentNode.removeChild(node); }; @@ -52,6 +71,10 @@ }; var data = askbot['data']; + var isAuthorOfPost = function(post_id) { + return (data['user_posts'] && data['user_posts'][post_id]); + }; + if (data['userIsAuthenticated']){ var votes = {}; {% for post_id in user_votes %} @@ -98,7 +121,11 @@ var repostAsPrevAnsComment = document.getElementById(id2); var extraOptsList = repostAsQuestionComment.parentNode; var extraOpts = extraOptsList.parentNode; - if (data['userIsAdminOrMod']){ + + var isAuthenticated = data['userIsAuthenticated']; + var isMod = data['userIsAdminOrMod']; + if (isAuthenticated && (isMod || isAuthorOfPost(post_id))) { + //still may need to hide because answer may be too long var answer_id = 'post-id-' + post_id; var answer_container = document.getElementById(answer_id); var answerBody = findChildrenByClassName(answer_container, 'answer-body')[0]; @@ -111,11 +138,12 @@ } else if (parseInt(post_id) === data['oldestAnswerId']) { repostAsPrevAnsComment.parentNode.removeChild(repostAsPrevAnsComment); } - } else{ + } else { repostAsQuestionComment.parentNode.removeChild(repostAsQuestionComment); repostAsPrevAnsComment.parentNode.removeChild(repostAsPrevAnsComment); } + //if the whole control is empty - remove it if (extraOptsList.getElementsByTagName('li').length === 0) { extraOpts.parentNode.removeChild(extraOpts); } @@ -210,13 +238,22 @@ } } - function hide_convert_links(){ - if (!askbot['data']['userIsAdminOrMod']){ - var links = findChildrenByClassName(document, 'convert-comment'); - for (i=0; i<links.length; i++){ - links[i].setAttribute('style', 'display:none;'); + function hide_convert_links() { + var isAuthenticated = data['userIsAuthenticated']; + var isMod = data['userIsAdminOrMod']; + if (isAuthenticated && isMod) { + return; + } + var convertForms = findChildrenByClassName(document, 'convert-comment'); + for (var i = 0; i < convertForms.length; i++) { + //get comment id + var form = convertForms[i]; + var idInput = findChildByAttribute(form, 'name', 'comment_id'); + var commentId = idInput.getAttribute('value'); + if (! isAuthorOfPost(commentId) ) { + form.setAttribute('style', 'display:none;'); + } } - } } askbot['functions'] = askbot['functions'] || {}; |