From: Charles Connell Date: Thu, 23 Jan 2014 15:49:25 +0000 (-0500) Subject: Don't show note uploads on dashboard, it's redundant X-Git-Tag: release-20150131~213 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=8e7dacf7c79bbf9b778daee5da2b0f700b5d96d1;p=oweals%2Fkarmaworld.git Don't show note uploads on dashboard, it's redundant --- diff --git a/karmaworld/apps/users/views.py b/karmaworld/apps/users/views.py index 8d5feab..7d60078 100644 --- a/karmaworld/apps/users/views.py +++ b/karmaworld/apps/users/views.py @@ -6,7 +6,6 @@ from itertools import chain from django.contrib.auth.models import User from django.views.generic import TemplateView from django.views.generic.list import MultipleObjectMixin -from karmaworld.apps.notes.models import Note from karmaworld.apps.users.models import ALL_KARMA_EVENT_CLASSES @@ -15,37 +14,15 @@ class ProfileView(TemplateView, MultipleObjectMixin): context_object_name = 'user' # name passed to template template_name = 'user_profile.html' - @staticmethod - def compareProfileItems(a, b): - if a.__class__ == Note: - timestampA = a.uploaded_at - else: - timestampA = a.timestamp - - if b.__class__ == Note: - timestampB = b.uploaded_at - else: - timestampB = b.timestamp - - if timestampA < timestampB: - return -1 - elif timestampA > timestampB: - return 1 - else: - return 0 - def get_context_data(self, **kwargs): - notes = [('note', o) for o in Note.objects.filter(user=self.request.user)] all_events = [] for cls in ALL_KARMA_EVENT_CLASSES: all_events.append( [(cls.__name__, o) for o in cls.objects.filter(user=self.request.user)] ) - all_events = chain.from_iterable(all_events) - result_list = sorted(chain(notes, all_events), - cmp=ProfileView.compareProfileItems, - key=lambda o: o[1], + result_list = sorted(chain.from_iterable(all_events), + key=lambda o: o[1].timestamp, reverse=True) kwargs['object_list'] = result_list diff --git a/karmaworld/templates/user_profile.html b/karmaworld/templates/user_profile.html index c37dc6d..5c67559 100644 --- a/karmaworld/templates/user_profile.html +++ b/karmaworld/templates/user_profile.html @@ -74,22 +74,6 @@
- {% if item.0 == 'note' %} - {% with note=item.1 %} -
-
- {{ note.uploaded_at|date:"D b j Y" }} -
-
- You uploaded {{ note.name }} -
- -
- {% endwith %} - {% endif %} - {% if 'KarmaEvent' in item.0 %} {% with event=item.1 %}