summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--askbot/conf/minimum_reputation.py3
-rw-r--r--askbot/conf/site_modes.py2
-rw-r--r--askbot/management/commands/askbot_import_jive.py2
-rw-r--r--askbot/models/__init__.py8
-rw-r--r--askbot/templates/faq_static.html2
-rw-r--r--askbot/templates/macros.html6
-rw-r--r--askbot/templates/question.html53
-rw-r--r--askbot/tests/permission_assertion_tests.py4
-rw-r--r--askbot/views/writers.py3
9 files changed, 68 insertions, 15 deletions
diff --git a/askbot/conf/minimum_reputation.py b/askbot/conf/minimum_reputation.py
index 799aebcc..94d5869e 100644
--- a/askbot/conf/minimum_reputation.py
+++ b/askbot/conf/minimum_reputation.py
@@ -68,6 +68,8 @@ settings.register(
)
)
+"""
+#this is disabled to possibly be completely removed later
settings.register(
livesettings.IntegerValue(
MIN_REP,
@@ -76,6 +78,7 @@ settings.register(
description=_('Leave comments')
)
)
+"""
settings.register(
livesettings.IntegerValue(
diff --git a/askbot/conf/site_modes.py b/askbot/conf/site_modes.py
index 06cd8d13..7c81341e 100644
--- a/askbot/conf/site_modes.py
+++ b/askbot/conf/site_modes.py
@@ -16,7 +16,7 @@ LARGE_SITE_MODE_SETTINGS = {
'MIN_REP_TO_ANSWER_OWN_QUESTION': 25,
'MIN_REP_TO_ACCEPT_OWN_ANSWER': 50,
'MIN_REP_TO_FLAG_OFFENSIVE': 15,
- 'MIN_REP_TO_LEAVE_COMMENTS': 50,
+ #'MIN_REP_TO_LEAVE_COMMENTS': 50,
'MIN_REP_TO_DELETE_OTHERS_COMMENTS': 2000,
'MIN_REP_TO_DELETE_OTHERS_POSTS': 5000,
'MIN_REP_TO_UPLOAD_FILES': 60,
diff --git a/askbot/management/commands/askbot_import_jive.py b/askbot/management/commands/askbot_import_jive.py
index ed094b63..04788c84 100644
--- a/askbot/management/commands/askbot_import_jive.py
+++ b/askbot/management/commands/askbot_import_jive.py
@@ -20,7 +20,7 @@ class Command(BaseCommand):
#relax certain settings
askbot_settings.update('LIMIT_ONE_ANSWER_PER_USER', False)
askbot_settings.update('MAX_COMMENT_LENGTH', 1000000)
- askbot_settings.update('MIN_REP_TO_LEAVE_COMMENTS', 1)
+ #askbot_settings.update('MIN_REP_TO_LEAVE_COMMENTS', 1)
self.bad_email_count = 0
def handle(self, *args, **kwargs):
diff --git a/askbot/models/__init__.py b/askbot/models/__init__.py
index 49ce7fae..017d4f87 100644
--- a/askbot/models/__init__.py
+++ b/askbot/models/__init__.py
@@ -771,6 +771,9 @@ def user_assert_can_edit_comment(self, comment = None):
def user_can_post_comment(self, parent_post = None):
"""a simplified method to test ability to comment
"""
+ return True
+ """
+ #commented out to disable the min rep
if self.reputation >= askbot_settings.MIN_REP_TO_LEAVE_COMMENTS:
return True
if parent_post and self == parent_post.author:
@@ -778,6 +781,7 @@ def user_can_post_comment(self, parent_post = None):
if self.is_administrator_or_moderator():
return True
return False
+ """
def user_assert_can_post_comment(self, parent_post = None):
@@ -795,7 +799,7 @@ def user_assert_can_post_comment(self, parent_post = None):
'Sorry, to comment any post a minimum reputation of '
'%(min_rep)s points is required. You can still comment '
'your own posts and answers to your questions'
- ) % {'min_rep': askbot_settings.MIN_REP_TO_LEAVE_COMMENTS}
+ ) % {'min_rep': 0}#askbot_settings.MIN_REP_TO_LEAVE_COMMENTS}
blocked_message = get_i18n_message('BLOCKED_USERS_CANNOT_POST')
@@ -806,7 +810,7 @@ def user_assert_can_post_comment(self, parent_post = None):
owner_can = True,
blocked_error_message = blocked_message,
suspended_error_message = suspended_error_message,
- min_rep_setting = askbot_settings.MIN_REP_TO_LEAVE_COMMENTS,
+ min_rep_setting = 0,#askbot_settings.MIN_REP_TO_LEAVE_COMMENTS,
low_rep_error_message = low_rep_error_message,
)
except askbot_exceptions.InsufficientReputation, e:
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'] || {};
diff --git a/askbot/tests/permission_assertion_tests.py b/askbot/tests/permission_assertion_tests.py
index 7f580dda..9d549450 100644
--- a/askbot/tests/permission_assertion_tests.py
+++ b/askbot/tests/permission_assertion_tests.py
@@ -893,7 +893,7 @@ class FlagOffensivePermissionAssertionTests(PermissionAssertionTestCase):
class CommentPermissionAssertionTests(PermissionAssertionTestCase):
def extraSetUp(self):
- self.min_rep = askbot_settings.MIN_REP_TO_LEAVE_COMMENTS
+ self.min_rep = 10#askbot_settings.MIN_REP_TO_LEAVE_COMMENTS
self.other_user = self.create_other_user()
def test_blocked_user_cannot_comment_own_question(self):
@@ -1079,6 +1079,7 @@ class CommentPermissionAssertionTests(PermissionAssertionTestCase):
)
)
+ """
def test_low_rep_user_cannot_comment_others(self):
question = self.post_question(
author = self.other_user
@@ -1096,6 +1097,7 @@ class CommentPermissionAssertionTests(PermissionAssertionTestCase):
question
)
)
+ """
def test_low_rep_user_can_comment_others_answer_to_own_question(self):
question = self.post_question()
diff --git a/askbot/views/writers.py b/askbot/views/writers.py
index e8d50cea..27c836d7 100644
--- a/askbot/views/writers.py
+++ b/askbot/views/writers.py
@@ -825,7 +825,6 @@ def delete_comment(request):
mimetype = 'application/json'
)
-@decorators.admins_only
@decorators.post_only
def comment_to_answer(request):
comment_id = request.POST.get('comment_id')
@@ -858,8 +857,8 @@ def comment_to_answer(request):
else:
raise Http404
-@decorators.admins_only
@decorators.post_only
+@csrf.csrf_protect
#todo: change the urls config for this
def repost_answer_as_comment(request, destination=None):
assert(