summaryrefslogtreecommitdiffstats
path: root/askbot/views
diff options
context:
space:
mode:
authorEvgeny Fadeev <evgeny.fadeev@gmail.com>2013-03-06 21:07:44 -0300
committerEvgeny Fadeev <evgeny.fadeev@gmail.com>2013-03-06 21:07:44 -0300
commit75681f982cafe1edd3f87b5114da6b2d684bccf1 (patch)
treeda8062a87d8cd0567b388ae9672b726f402f8c8a /askbot/views
parent37250b7cfe88cbcf22f8ca61fbe1f39d04a4e0cd (diff)
parentd13ee8aa889304ca95cbd8cc777ab5e957fbed54 (diff)
downloadaskbot-75681f982cafe1edd3f87b5114da6b2d684bccf1.tar.gz
askbot-75681f982cafe1edd3f87b5114da6b2d684bccf1.tar.bz2
askbot-75681f982cafe1edd3f87b5114da6b2d684bccf1.zip
merged the master branch
Diffstat (limited to 'askbot/views')
-rw-r--r--askbot/views/readers.py1
-rw-r--r--askbot/views/writers.py27
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()