完成了课程资源列表的排序(上传时间,资源大小,下载次数)

ouyangxuhua
linchun 10 years ago
parent d3ed89d87e
commit 3fcf192430

@ -63,11 +63,18 @@ class AdminController < ApplicationController
def course_resource_list def course_resource_list
#sort_init 'created_on','desc' #sort_init 'created_on','desc'
#sort_update %w(filename filesize filetype created_on downloads author course) #sort_update %w(filename filesize filetype created_on downloads author course)
if params[:file_size] if params[:sort] == 'file_size'
@resource = Attachment.where(:container_type => 'Course').order("filesize desc")
elsif params[:sort] == 'file_upload'
@resource = Attachment.where(:container_type => 'Course').order("created_on desc")
elsif params[:sort] == 'file_download_times'
@resource = Attachment.where(:container_type => 'Course').order("downloads desc") @resource = Attachment.where(:container_type => 'Course').order("downloads desc")
else else
@resource = Attachment.where(:container_type => 'Course').order("created_on desc") @resource = Attachment.where(:container_type => 'Course').order("created_on desc")
end end
@resource = paginateHelper @resource,30 @resource = paginateHelper @resource,30
@page = (params['page'] || 1).to_i - 1 @page = (params['page'] || 1).to_i - 1

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

Loading…
Cancel
Save