From: Charles Connell Date: Wed, 23 Apr 2014 15:57:18 +0000 (-0400) Subject: Sort by school X-Git-Tag: release-20150131~134 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=a3f84bd747438487f68058845d3438fbfaf0ce5e;p=oweals%2Fkarmaworld.git Sort by school --- 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 }}