diff options
Diffstat (limited to 'askbot/views')
-rw-r--r-- | askbot/views/readers.py | 1 | ||||
-rw-r--r-- | askbot/views/writers.py | 27 |
2 files changed, 25 insertions, 3 deletions
diff --git a/askbot/views/readers.py b/askbot/views/readers.py index 7fbcf6d0..51a4da8e 100644 --- a/askbot/views/readers.py +++ b/askbot/views/readers.py @@ -598,6 +598,7 @@ def question(request, id):#refactor - long subroutine. display question body, an 'user_post_id_list': user_post_id_list, 'user_can_post_comment': user_can_post_comment,#in general 'user_already_gave_answer': user_already_gave_answer, + 'oldest_answer_id': thread.get_oldest_answer_id(request.user), 'previous_answer': previous_answer, 'tab_id' : answer_sort_method, 'favorited' : favorited, diff --git a/askbot/views/writers.py b/askbot/views/writers.py index 74c96235..d767fe77 100644 --- a/askbot/views/writers.py +++ b/askbot/views/writers.py @@ -812,22 +812,43 @@ def comment_to_answer(request): @decorators.admins_only @decorators.post_only -def answer_to_comment(request): +#todo: change the urls config for this +def repost_answer_as_comment(request, destination=None): + assert( + destination in ( + 'comment_under_question', + 'comment_under_previous_answer' + ) + ) answer_id = request.POST.get('answer_id') if answer_id: answer_id = int(answer_id) answer = get_object_or_404(models.Post, post_type = 'answer', id=answer_id) + + if destination == 'comment_under_question': + destination_post = answer.thread._question_post() + else: + #comment_under_previous_answer + destination_post = answer.get_previous_answer(user=request.user) + #todo: implement for comment under other answer + + if destination_post is None: + message = _('Error - could not find the destination post') + request.user.message_set.create(message=message) + return HttpResponseRedirect(answer.get_absolute_url()) + if len(answer.text) <= askbot_settings.MAX_COMMENT_LENGTH: answer.post_type = 'comment' - answer.parent = answer.thread._question_post() + answer.parent = destination_post #can we trust this? old_comment_count = answer.comment_count answer.comment_count = 0 answer_comments = models.Post.objects.get_comments().filter(parent=answer) - answer_comments.update(parent=answer.parent) + answer_comments.update(parent=destination_post) + #why this and not just "save"? answer.parse_and_save(author=answer.author) answer.thread.update_answer_count() |