From 7d5a5f1de28bcfb8f96969c3686050b93819f0a6 Mon Sep 17 00:00:00 2001 From: linchun Date: Tue, 15 Mar 2016 16:14:53 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E9=A1=B9=E7=9B=AE=E8=B5=84?= =?UTF-8?q?=E6=BA=90=E5=88=97=E8=A1=A8=E4=B8=AD=E7=9A=84=E6=8E=92=E5=BA=8F?= =?UTF-8?q?=EF=BC=88=E8=B5=84=E6=BA=90=E5=A4=A7=E5=B0=8F=EF=BC=8C=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0=E6=97=B6=E9=97=B4=EF=BC=8C=E4=B8=8B=E8=BD=BD=E6=AC=A1?= =?UTF-8?q?=E6=95=B0=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/admin_controller.rb | 17 ++++++++++++----- app/views/admin/project_resource_list.html.erb | 6 +++--- 2 files changed, 15 insertions(+), 8 deletions(-) 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") %> 上传者