diff options
Diffstat (limited to 'askbot')
-rw-r--r-- | askbot/skins/default/templates/badge.html | 10 | ||||
-rw-r--r-- | askbot/views/meta.py | 19 |
2 files changed, 12 insertions, 17 deletions
diff --git a/askbot/skins/default/templates/badge.html b/askbot/skins/default/templates/badge.html index 6d4c956e..ef5d3a89 100644 --- a/askbot/skins/default/templates/badge.html +++ b/askbot/skins/default/templates/badge.html @@ -12,14 +12,14 @@ </p> <div> {% if badge.awarded_count %} - <p style="float:left"><span class="count">{{ awards|length|intcomma }}</span> - <strong>{% trans num_awardees=awards|length %}user received this badge:{% pluralize %}users received this badge:{% endtrans %}</strong></p> + <p style="float:left"><span class="count">{{ badge_recipients|length|intcomma }}</span> + <strong>{% trans num_awardees=badge_recipients|length %}user received this badge:{% pluralize %}users received this badge:{% endtrans %}</strong></p> {% endif %} </div> <div id="award-list" style="clear:both;margin-left:20px;line-height:25px;"> - {% for award in awards %} - <p style="width:180px;float:left"><a href="{{ award.user.get_absolute_url() }}">{{ award.user.username }}</a> - {{ macros.user_score_and_badge_summary(award.user) }} + {% for recipient in badge_recipients %} + <p style="width:180px;float:left"><a href="{{ recipient.get_absolute_url() }}">{{ recipient.username }}</a> + {{ macros.user_score_and_badge_summary(recipient) }} </p> {% endfor %} </div> diff --git a/askbot/views/meta.py b/askbot/views/meta.py index 4aba646d..72d479c6 100644 --- a/askbot/views/meta.py +++ b/askbot/views/meta.py @@ -13,7 +13,7 @@ from django.views import static from askbot.forms import FeedbackForm from askbot.utils.forms import get_next_url from askbot.utils.mail import mail_moderators -from askbot.models import BadgeData, Award +from askbot.models import BadgeData, Award, User from askbot.models import badges as badge_data from askbot.skins.loaders import ENV from askbot import skins @@ -116,22 +116,17 @@ def badges(request):#user status/reputation system def badge(request, id): #todo: supplement database data with the stuff from badges.py badge = get_object_or_404(BadgeData, id=id) - awards = Award.objects.filter( - badge = badge, - ).select_related( - 'user__id', - 'user__username', - 'user__reputation', - 'user__gold', - 'user__silver', - 'user__bronze' - ).distinct('user') + badge_recipients = User.objects.filter( + award_user__badge = badge + ).order_by( + '-award_user__awarded_at' + ).distinct() template = ENV.get_template('badge.html') data = { 'view_name': badge, 'active_tab': 'badges', - 'awards' : awards, + 'badge_recipients' : badge_recipients, 'badge' : badge, } context = RequestContext(request, data) |