reverting previous optimization as it didn't optimize and it did obfuscate.
authorBryan <btbonval@gmail.com>
Tue, 25 Feb 2014 01:02:58 +0000 (20:02 -0500)
committerBryan <btbonval@gmail.com>
Tue, 25 Feb 2014 01:02:58 +0000 (20:02 -0500)
karmaworld/apps/courses/templatetags/__init__.py [deleted file]
karmaworld/apps/courses/templatetags/dict_filters.py [deleted file]
karmaworld/apps/courses/views.py
karmaworld/templates/courses/course_list_entry.html

diff --git a/karmaworld/apps/courses/templatetags/__init__.py b/karmaworld/apps/courses/templatetags/__init__.py
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/karmaworld/apps/courses/templatetags/dict_filters.py b/karmaworld/apps/courses/templatetags/dict_filters.py
deleted file mode 100644 (file)
index cad27ad..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-from django import template
-
-register = template.Library()
-
-@register.filter(name='get')
-def get(obj, key):
-    """ Call getitem against the given key. """
-    return obj[key]
index 5b68ad051a45c3d9ef595d48b19df25849580f59..b88fe7b5a2be99601bac918a044ddb0a4c71114f 100644 (file)
@@ -5,7 +5,6 @@
 
 import json
 
-from django.db.models import Sum
 from django.core import serializers
 from django.core.exceptions import MultipleObjectsReturned
 from django.core.exceptions import ObjectDoesNotExist
@@ -50,12 +49,6 @@ class CourseListView(ListView, ModelFormMixin, ProcessFormView):
         # Include "Add Course" button in header
         context['display_add_course'] = True
 
-        # Include courses to number of total note thanks mapping
-        # See Course.get_popularity for a more detailed explanation.
-        thanks = Course.objects.values('id').annotate(sum=Sum('note__thanks'))
-        # Create a generator to convert the list of dicts into a dict.
-        context['course_thanks'] = dict((x['id'],x['sum'] or 0) for x in thanks)
-
         return context
 
     def get_success_url(self):
index b1417f0982226110e287c86e36f3dd851696d1a8..18fd2fca2588fc105c88eecb898f7ffd051d6b34 100644 (file)
@@ -1,9 +1,8 @@
-{% load dict_filters %}
 <tr>
   <td class="no-display"><!-- this spot solely for the Sort By header --></td>
   <td class="small-8 columns large-4 slim"><span>Updated {{ course.updated_at|date:"b d, o"|capfirst }}</span></td>
   <td class="small-4 columns large-2 large-offset-2 slim"><span>{{ course.file_count }} Notes</span></td>
-  <td class="small-4 columns large-2 large-offset-1 slim"><span>{{ course_thanks|get:course.id }} Thanks</span></td>
+  <td class="small-4 columns large-2 large-offset-1 slim"><span>{{ course.get_popularity }} Thanks</span></td>
 
   <td class="small-12 large-5 columns">
     <a href="{{ course.get_absolute_url }}">{% if course.department %}{{course.department.name}}: {% endif %}{{ course.name }}</a>