diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 2b44ce34b..d93959996 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -61,8 +61,7 @@ class AdminController < ApplicationController #管理员界面课程资源列表 def course_resource_list - #sort_init 'created_on','desc' - #sort_update %w(filename filesize filetype created_on downloads author course) + if params[:sort] == 'file_size' @resource = Attachment.where(:container_type => 'Course').order("filesize desc") elsif params[:sort] == 'file_upload' @@ -73,8 +72,6 @@ class AdminController < ApplicationController @resource = Attachment.where(:container_type => 'Course').order("created_on desc") end - - @resource = paginateHelper @resource,30 @page = (params['page'] || 1).to_i - 1 @@ -85,7 +82,17 @@ class AdminController < ApplicationController #管理员界面項目资源列表 def project_resource_list - @pro_resource = Attachment.where(:container_type => 'Project') + + if params[:sort] == 'file_size' + @pro_resource = Attachment.where(:container_type => 'Project').order("filesize desc") + elsif params[:sort] == 'file_upload' + @pro_resource = Attachment.where(:container_type => 'Project').order("created_on desc") + elsif params[:sort] == 'file_download_times' + @pro_resource = Attachment.where(:container_type => 'Project').order("downloads desc") + else + @pro_resource = Attachment.where(:container_type => 'Project').order("created_on desc") + end + @pro_resource = paginateHelper @pro_resource,30 @page = (params['page'] || 1).to_i - 1 diff --git a/app/views/admin/project_resource_list.html.erb b/app/views/admin/project_resource_list.html.erb index c245f73b8..e82831546 100644 --- a/app/views/admin/project_resource_list.html.erb +++ b/app/views/admin/project_resource_list.html.erb @@ -10,16 +10,16 @@ 资源名称 - 资源大小 + <%= link_to "资源大小",admin_project_resource_list_path(:sort => "file_size") %> 资源类型 - 上传时间 + <%= link_to "上传时间",admin_project_resource_list_path(:sort => "file_upload") %> - 下载次数 + <%= link_to "下载次数",admin_project_resource_list_path(:sort => "file_download_times") %> 上传者