]> git.openstreetmap.org Git - osqa.git/commitdiff
Jira OSQA-456, avoid using nested loops, use the 'in' operator in the template instead.
authorjordan <jordan@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Sun, 31 Jul 2011 12:22:09 +0000 (12:22 +0000)
committerjordan <jordan@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Sun, 31 Jul 2011 12:22:09 +0000 (12:22 +0000)
git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@1137 0cfe37f9-358a-4d5e-be75-b63607b5c754

forum/skins/default/templates/badges.html
forum/views/meta.py

index 016cc71d0073bc99d36c91ee2eda21e8ba95b36e..7184204d519a241704cd67db1201d5059141c179 100644 (file)
         {% for badge in badges %}
         <div style="clear:both;line-height:30px">
             <div style="float:left;min-width:30px;text-align:right;height:30px">
-            {% for a in mybadges %}
-                {% ifequal a.badge_id badge.id %}
+            {% if badge.id in mybadges %}
                  <span style="font-size:175%; padding-right:5px; color:#5B9058;">&#10004;</span>
-                {% endifequal %}
-            {% endfor %}
+            {% endif %}
             </div>
             <div style="float:left;width:230px;">
                 <a href="{{badge.get_absolute_url}}" title="{{ badge.get_type_display }} : {{ badge.description }}" class="medal"><span class="badge{{ badge.type }}">&#9679;</span>&nbsp;{{ badge.name }}</a><strong> &#215; {{ badge.awarded_count|intcomma }}</strong>
index f4f1a80121c84e8091034ac53bc9ac8303b2246c..c9548e58d46e34d6af9780503e59de1577b70797 100644 (file)
@@ -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 = []