From a3f84bd747438487f68058845d3438fbfaf0ce5e Mon Sep 17 00:00:00 2001 From: Charles Connell Date: Wed, 23 Apr 2014 11:57:18 -0400 Subject: [PATCH] Sort by school --- karmaworld/assets/js/course-list.js | 14 ++++++++++++-- karmaworld/templates/courses/course_list.html | 10 ++++++---- .../templates/courses/course_list_entry.html | 5 +++++ 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/karmaworld/assets/js/course-list.js b/karmaworld/assets/js/course-list.js index 3d4642a..68cc0cb 100644 --- a/karmaworld/assets/js/course-list.js +++ b/karmaworld/assets/js/course-list.js @@ -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)]]); }); diff --git a/karmaworld/templates/courses/course_list.html b/karmaworld/templates/courses/course_list.html index d2a13cd..9843904 100644 --- a/karmaworld/templates/courses/course_list.html +++ b/karmaworld/templates/courses/course_list.html @@ -58,6 +58,7 @@ + @@ -70,10 +71,11 @@ - - - - + + + + + diff --git a/karmaworld/templates/courses/course_list_entry.html b/karmaworld/templates/courses/course_list_entry.html index 8ae41ab..9950563 100644 --- a/karmaworld/templates/courses/course_list_entry.html +++ b/karmaworld/templates/courses/course_list_entry.html @@ -2,6 +2,11 @@ + {% if course.school %} + + {% else %} + + {% endif %}
Date # Notes Popularity Course Date# NotesPopularitySchoolCourse
{{ course.updated_at|date:"U" }} {{ course.file_count|stringformat:"010g" }} {{ course.get_popularity|stringformat:"010g" }}{{ course.school.name }}{{ course.department.school.name }}
-- 2.25.1