Don't show note uploads on dashboard, it's redundant
authorCharles Connell <charles@connells.org>
Thu, 23 Jan 2014 15:49:25 +0000 (10:49 -0500)
committerCharles Connell <charles@connells.org>
Thu, 23 Jan 2014 16:50:06 +0000 (11:50 -0500)
karmaworld/apps/users/views.py
karmaworld/templates/user_profile.html

index 8d5feab82744e808586cd064377374021e6ec76a..7d60078157f3a5a3aa919767b96e179c081f8215 100644 (file)
@@ -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
index c37dc6d60547249afc1a4c224ad11aa445922b23..5c6755961194fe8552e7fa5ccba50d501da287ec 100644 (file)
           <div class="small-10 columns small-centered {% cycle '' 'row_alt_on'%}">
 
             <div class="activity_item">
-              {% if item.0 == 'note' %}
-                {% with note=item.1 %}
-                  <div class="row">
-                    <div class="small-12 columns activity_timestamp">
-                      <span class="activity_date">{{ note.uploaded_at|date:"D b j Y" }}</span>
-                    </div>
-                    <div class="small-12 columns activity_details_action">
-                      You uploaded <a href="{{ note.get_absolute_url }}" class="activity_target">{{ note.name }}</a>
-                    </div>
-                    <div class="small-12 columns activity_details_context">
-                      <a href="{{ note.course.get_absolute_url }}" class="course_link">{{ note.course.name }} // {{ note.course.school.name }}</a>
-                    </div>
-                  </div>
-                {% endwith %}
-              {% endif %}
-
               {% if 'KarmaEvent' in item.0 %}
                 {% with event=item.1 %}
                   <div class="row">