From 1cd804f934d6d4b12ca8f43d898fe0f1e4a2b880 Mon Sep 17 00:00:00 2001 From: Bryan Date: Mon, 24 Feb 2014 20:02:58 -0500 Subject: [PATCH] reverting previous optimization as it didn't optimize and it did obfuscate. --- karmaworld/apps/courses/templatetags/__init__.py | 0 karmaworld/apps/courses/templatetags/dict_filters.py | 8 -------- karmaworld/apps/courses/views.py | 7 ------- karmaworld/templates/courses/course_list_entry.html | 3 +-- 4 files changed, 1 insertion(+), 17 deletions(-) delete mode 100644 karmaworld/apps/courses/templatetags/__init__.py delete mode 100644 karmaworld/apps/courses/templatetags/dict_filters.py 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 }} -- 2.25.1