Sort by school
authorCharles Connell <charles@connells.org>
Wed, 23 Apr 2014 15:57:18 +0000 (11:57 -0400)
committerCharles Connell <charles@connells.org>
Wed, 23 Apr 2014 15:57:18 +0000 (11:57 -0400)
karmaworld/assets/js/course-list.js
karmaworld/templates/courses/course_list.html
karmaworld/templates/courses/course_list_entry.html

index 3d4642a710834910aca6dbf3af8e4403653c8105..68cc0cbada3beeaece4d503b224e611ca6287b98 100644 (file)
@@ -40,14 +40,24 @@ $(function() {
     dataTable.fnFilter($(this).val());
   });
 
+  function sortDirection(col) {
+    if (col == 3) {
+      return 'asc';
+    } else {
+      return 'desc';
+    }
+  }
+
   // wire up sort chooser
   $('select.course-sort').change(function() {
-    dataTable.fnSort([[$(this).val(), 'desc']]);
+    var sortCol = $(this).val();
+    dataTable.fnSort([[sortCol, sortDirection(sortCol)]]);
   });
 
   // sort by current value of sort chooser, since
   // the browser may change this from our default
-  dataTable.fnSort([[$('select.course-sort').val(), 'desc']]);
+  var sortCol = $('select.course-sort').val();
+  dataTable.fnSort([[sortCol, sortDirection(sortCol)]]);
 
 });
 
index d2a13cd3c4ec335e8a3bd7e24d333bd5e0890dfc..9843904105e276080e2ffb56512aec5ad68459ae 100644 (file)
@@ -58,6 +58,7 @@
             <option value="0">Date</option>
             <option value="1">Number of Notes</option>
             <option value="2" selected>Popularity</option>
+            <option value="3">School</option>
           </select>
         </div>
       </div>
       <table id="data_table_list">
         <thead class="hide">
           <tr>
-            <th class="no-display" id="data-table-date"> Date </th>
-            <th class="no-display" id="data-table-note-count"> # Notes </th>
-            <th class="no-display" id="data-table-thanks"> Popularity </th>
-            <th class="no-display" id="data-table-upload"> Course </th>
+            <th class="no-display" id="data-table-date">Date</th>
+            <th class="no-display" id="data-table-note-count"># Notes</th>
+            <th class="no-display" id="data-table-thanks">Popularity</th>
+            <th class="no-display" id="data-table-school">School</th>
+            <th class="no-display" id="data-table-course">Course</th>
           </tr>
         </thead>
         <tbody>
index 8ae41abab7340ab2e2af2d241922273f90cb9003..9950563a21a3078abb5220883bf7fc172a9eb2ee 100644 (file)
@@ -2,6 +2,11 @@
   <td class="hide">{{ course.updated_at|date:"U" }}</td>
   <td class="hide">{{ course.file_count|stringformat:"010g" }}</td>
   <td class="hide">{{ course.get_popularity|stringformat:"010g" }}</td>
+  {% if course.school %}
+    <td class="hide">{{ course.school.name }}</td>
+  {% else %}
+    <td class="hide">{{ course.department.school.name }}</td>
+  {% endif %}
 
   <td class="small-12 columns">
     <div class="data-table-entry">