From be328f5cc3e5db72f5a4551b126130bf1feea82a Mon Sep 17 00:00:00 2001 From: Alban Tiberghien Date: Mon, 30 Jul 2012 19:50:33 +0300 Subject: Fix get_badge_summary --- askbot/models/__init__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/askbot/models/__init__.py b/askbot/models/__init__.py index 686190b7..c1beb594 100644 --- a/askbot/models/__init__.py +++ b/askbot/models/__init__.py @@ -2191,14 +2191,14 @@ def user_get_badge_summary(self): bit = ungettext( 'one silver badge', '%(count)d silver badges', - self.gold + self.silver ) % {'count': self.silver} badge_bits.append(bit) - if self.silver: + if self.bronze: bit = ungettext( 'one bronze badge', '%(count)d bronze badges', - self.gold + self.bronze ) % {'count': self.bronze} badge_bits.append(bit) -- cgit v1.2.3-1-g7c22 From c9bc80fdb6316cfe377790c3a038ba017c89d246 Mon Sep 17 00:00:00 2001 From: Evgeny Fadeev Date: Tue, 31 Jul 2012 21:32:03 -0400 Subject: small change in the code calculating similar questions --- askbot/models/question.py | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/askbot/models/question.py b/askbot/models/question.py index 0fd02bf0..2bb9e80a 100644 --- a/askbot/models/question.py +++ b/askbot/models/question.py @@ -641,6 +641,8 @@ class Thread(models.Model): """ def get_data(): + # todo: code in this function would be simpler if + # we had question post id denormalized on the thread tags_list = self.get_tag_names() similar_threads = Thread.objects.filter( tags__name__in=tags_list @@ -659,20 +661,28 @@ class Thread(models.Model): similar_threads = similar_threads[:10] # Denormalize questions to speed up template rendering + # todo: just denormalize question_post_id on the thread! thread_map = dict([(thread.id, thread) for thread in similar_threads]) questions = Post.objects.get_questions() questions = questions.select_related('thread').filter(thread__in=similar_threads) for q in questions: thread_map[q.thread_id].question_denorm = q - # Postprocess data - similar_threads = [ - { - 'url': thread.question_denorm.get_absolute_url(), - 'title': thread.get_title(thread.question_denorm) - } for thread in similar_threads - ] - return similar_threads + # Postprocess data for the final output + result = list() + for thread in similar_threads: + question_post = getattr(thread, 'question_denorm', None) + # unfortunately the if statement below is necessary due to + # a possible bug + # all this proves that it's wrong to reference threads by + # the question post id in the question page urls!!! + # this is a "legacy" problem inherited from the old models + if question_post: + url = question_post.get_absolute_url() + title = thread.get_title(question_post) + result.append({'url': url, 'title': title}) + + return result def get_cached_data(): """similar thread data will expire -- cgit v1.2.3-1-g7c22 From ca2c6aa73f31ba1adb5dd62a416807773fb369f3 Mon Sep 17 00:00:00 2001 From: Evgeny Fadeev Date: Wed, 8 Aug 2012 12:41:15 -0400 Subject: fixed voting bug in js on the question page --- askbot/skins/default/templates/question/javascript.html | 7 +------ askbot/skins/default/templates/question/sidebar.html | 8 +++++++- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/askbot/skins/default/templates/question/javascript.html b/askbot/skins/default/templates/question/javascript.html index 73e209bb..af0b0829 100644 --- a/askbot/skins/default/templates/question/javascript.html +++ b/askbot/skins/default/templates/question/javascript.html @@ -30,12 +30,7 @@