From ddc60c4eb1d0693975aba37f72c9f8fde55299bc Mon Sep 17 00:00:00 2001 From: Evgeny Fadeev Date: Mon, 26 Nov 2012 11:28:59 -0300 Subject: fixed hardcoded maximum comment length in the answer -> comment conversion --- askbot/templates/meta/html_head_javascript.html | 1 + askbot/templates/question.html | 5 ++++- askbot/views/writers.py | 8 ++++++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/askbot/templates/meta/html_head_javascript.html b/askbot/templates/meta/html_head_javascript.html index 09362baa..306f325a 100644 --- a/askbot/templates/meta/html_head_javascript.html +++ b/askbot/templates/meta/html_head_javascript.html @@ -19,6 +19,7 @@ askbot['data']['userIsAuthenticated'] = false; askbot['data']['userReputation'] = 0; {% endif %} + askbot['data']['maxCommentLength'] = {{settings.MAX_COMMENT_LENGTH}}; askbot['urls'] = {}; askbot['settings'] = {}; askbot['settings']['editorType'] = '{{ settings.EDITOR_TYPE }}'; diff --git a/askbot/templates/question.html b/askbot/templates/question.html index 57c71068..5a317707 100644 --- a/askbot/templates/question.html +++ b/askbot/templates/question.html @@ -63,7 +63,10 @@ var answer_id = 'post-id-' + post_id; var answer_container = document.getElementById(answer_id); var answer_element= answer_container.getElementsByClassName('answer-body')[0].children[1]; - if (answer_element.textContent.length > 300){ + if ( + answer_element.textContent.length > + askbot['data']['maxCommentLength'] + ){ convert_answer.parentNode.removeChild(convert_answer); } } else{ diff --git a/askbot/views/writers.py b/askbot/views/writers.py index da4ce6a1..fadacd1f 100644 --- a/askbot/views/writers.py +++ b/askbot/views/writers.py @@ -772,7 +772,7 @@ def answer_to_comment(request): answer_id = int(answer_id) answer = get_object_or_404(models.Post, post_type = 'answer', id=answer_id) - if len(answer.text) <= 300: + if len(answer.text) <= askbot_settings.MAX_COMMENT_LENGTH: answer.post_type = 'comment' answer.parent = answer.thread._question_post() #can we trust this? @@ -790,7 +790,11 @@ def answer_to_comment(request): answer.thread.invalidate_cached_data() else: - request.user.message_set.create(message = _("the selected answer cannot be a comment")) + message = _( + 'Cannot convert, because text has more characters than ' + '%(max_chars)s - maximum allowed for comments' + ) % askbot_settings.MAX_COMMENT_LENGTH + request.user.message_set.create(message=message) return HttpResponseRedirect(answer.get_absolute_url()) else: -- cgit v1.2.3-1-g7c22 From ac052de56b2942a5d5421b5d475716037f269897 Mon Sep 17 00:00:00 2001 From: Evgeny Fadeev Date: Mon, 26 Nov 2012 12:23:55 -0300 Subject: fixed bug not allowing highlighting of text with tinymce --- askbot/models/post.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/askbot/models/post.py b/askbot/models/post.py index ce7b249b..bde6acaf 100644 --- a/askbot/models/post.py +++ b/askbot/models/post.py @@ -416,11 +416,11 @@ class Post(models.Model): if self.post_type in ('question', 'answer', 'tag_wiki', 'reject_reason'): _urlize = False - _use_markdown = True + _use_markdown = (askbot_settings.EDITOR_TYPE == 'markdown') _escape_html = False #markdow does the escaping elif self.is_comment(): _urlize = True - _use_markdown = True + _use_markdown = (askbot_settings.EDITOR_TYPE == 'markdown') _escape_html = True else: raise NotImplementedError -- cgit v1.2.3-1-g7c22