diff options
author | sailingcai <sailingcai@gmail.com> | 2009-10-14 00:27:59 +0800 |
---|---|---|
committer | sailingcai <sailingcai@gmail.com> | 2009-10-14 00:27:59 +0800 |
commit | e02cd69de6b6c534792ba12b1ac10e01e04318c2 (patch) | |
tree | 6e54c5667b0c0b3b778239e32fd2aee62f9bb73c /forum/views.py | |
parent | 0a6e82562c5c910cef4711e30a04ef866b805e32 (diff) | |
download | askbot-e02cd69de6b6c534792ba12b1ac10e01e04318c2.tar.gz askbot-e02cd69de6b6c534792ba12b1ac10e01e04318c2.tar.bz2 askbot-e02cd69de6b6c534792ba12b1ac10e01e04318c2.zip |
1. Optimize get votes in answers
Diffstat (limited to 'forum/views.py')
-rw-r--r-- | forum/views.py | 9 |
1 files changed, 4 insertions, 5 deletions
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: |