From e02cd69de6b6c534792ba12b1ac10e01e04318c2 Mon Sep 17 00:00:00 2001 From: sailingcai Date: Wed, 14 Oct 2009 00:27:59 +0800 Subject: 1. Optimize get votes in answers --- forum/views.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'forum/views.py') diff --git a/forum/views.py b/forum/views.py index 5e53644f..cfadaa48 100644 --- a/forum/views.py +++ b/forum/views.py @@ -338,14 +338,13 @@ def question(request, id): question_vote = question_vote[0] user_answer_votes = {} - for answer in answers: - vote = answer.get_user_vote(request.user) - if vote is not None and not user_answer_votes.has_key(answer.id): + for vote in question.get_user_votes_in_answers(request.user): + if not user_answer_votes.has_key(vote.object_id): vote_value = -1 if vote.is_upvote(): vote_value = 1 - user_answer_votes[answer.id] = vote_value - + user_answer_votes[vote.object_id] = vote_value + filtered_answers = [] for answer in answers: if answer.deleted == True: -- cgit v1.2.3-1-g7c22