From: jordan Date: Sun, 31 Jul 2011 12:22:09 +0000 (+0000) Subject: Jira OSQA-456, avoid using nested loops, use the 'in' operator in the template instead. X-Git-Tag: live~176 X-Git-Url: https://git.openstreetmap.org./osqa.git/commitdiff_plain/ba92fb664319b9026ffd19aa5f837227470b426c Jira OSQA-456, avoid using nested loops, use the 'in' operator in the template instead. git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@1137 0cfe37f9-358a-4d5e-be75-b63607b5c754 --- diff --git a/forum/skins/default/templates/badges.html b/forum/skins/default/templates/badges.html index 016cc71..7184204 100644 --- a/forum/skins/default/templates/badges.html +++ b/forum/skins/default/templates/badges.html @@ -18,11 +18,9 @@ {% for badge in badges %}
- {% for a in mybadges %} - {% ifequal a.badge_id badge.id %} + {% if badge.id in mybadges %} - {% endifequal %} - {% endfor %} + {% endif %}
 {{ badge.name }} × {{ badge.awarded_count|intcomma }} diff --git a/forum/views/meta.py b/forum/views/meta.py index f4f1a80..c9548e5 100644 --- a/forum/views/meta.py +++ b/forum/views/meta.py @@ -91,7 +91,7 @@ def badges(request): badges = sorted([Badge.objects.get(id=id) for id in BadgesMeta.by_id.keys()], lambda b1, b2: cmp(b1.name, b2.name)) if request.user.is_authenticated(): - my_badges = Award.objects.filter(user=request.user).values('badge_id').distinct() + my_badges = Award.objects.filter(user=request.user).values_list('badge_id', flat=True).distinct() else: my_badges = []