完成项目资源列表中的排序(资源大小,上传时间,下载次数)

This commit is contained in:
linchun 2016-03-15 16:14:53 +08:00
parent 3fcf192430
commit 7d5a5f1de2
2 changed files with 15 additions and 8 deletions

View File

@ -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

View File

@ -10,16 +10,16 @@
资源名称
</th>
<th style="width: 30px;">
资源大小
<%= link_to "资源大小",admin_project_resource_list_path(:sort => "file_size") %>
</th>
<th style="width: 25px;">
资源类型
</th>
<th style="width: 23px;">
上传时间
<%= link_to "上传时间",admin_project_resource_list_path(:sort => "file_upload") %>
</th>
<th style="width: 15px;">
下载次数
<%= link_to "下载次数",admin_project_resource_list_path(:sort => "file_download_times") %>
</th>
<th style="width: 20px;">
上传者