From: Bryan Date: Tue, 25 Feb 2014 01:02:58 +0000 (-0500) Subject: reverting previous optimization as it didn't optimize and it did obfuscate. X-Git-Tag: release-20150131~163^2~5 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=1cd804f934d6d4b12ca8f43d898fe0f1e4a2b880;p=oweals%2Fkarmaworld.git reverting previous optimization as it didn't optimize and it did obfuscate. --- diff --git a/karmaworld/apps/courses/templatetags/__init__.py b/karmaworld/apps/courses/templatetags/__init__.py deleted file mode 100644 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 index cad27ad..0000000 --- a/karmaworld/apps/courses/templatetags/dict_filters.py +++ /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] diff --git a/karmaworld/apps/courses/views.py b/karmaworld/apps/courses/views.py index 5b68ad0..b88fe7b 100644 --- a/karmaworld/apps/courses/views.py +++ b/karmaworld/apps/courses/views.py @@ -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): diff --git a/karmaworld/templates/courses/course_list_entry.html b/karmaworld/templates/courses/course_list_entry.html index b1417f0..18fd2fc 100644 --- a/karmaworld/templates/courses/course_list_entry.html +++ b/karmaworld/templates/courses/course_list_entry.html @@ -1,9 +1,8 @@ -{% load dict_filters %} Updated {{ course.updated_at|date:"b d, o"|capfirst }} {{ course.file_count }} Notes - {{ course_thanks|get:course.id }} Thanks + {{ course.get_popularity }} Thanks {% if course.department %}{{course.department.name}}: {% endif %}{{ course.name }}