@ -24,7 +24,7 @@ class AdminController < ApplicationController
before_filter :require_admin
helper :sort
helper :Users
helper :Settings
helper :Settings , SchoolHelper
include SortHelper
def index
@ -65,7 +65,17 @@ class AdminController < ApplicationController
#管理员界面课程资源列表
def course_resource_list
@resource = Attachment . where ( :container_type = > 'Course' )
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 " )
else
@resource = Attachment . where ( :container_type = > 'Course' ) . order ( " created_on desc " )
end
@resource = paginateHelper @resource , 30
@page = ( params [ 'page' ] || 1 ) . to_i - 1
@ -76,7 +86,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
@ -92,9 +112,9 @@ class AdminController < ApplicationController
case params [ :format ]
when 'xml' , 'json'
@offset , @limit = api_offset_and_limit ( { :limit = > 1 5} )
@offset , @limit = api_offset_and_limit ( { :limit = > 50 } )
else
@limit = 1 5#per_page_option
@limit = 50 #per_page_option
end
@status = params [ :status ] || 1
@ -374,7 +394,13 @@ class AdminController < ApplicationController
#组织
def organization
@organizations = Organization . all
@organizations = Organization . find_by_sql ( " SELECT * FROM organizations ORDER BY created_at DESC " )
#@organizations = Organization.all.order("created_at desc")
@organization_count = @organizations . count
@organization_pages = Paginator . new @organization_count , 30 , params [ 'page' ] || 1
@organizations = paginateHelper @organizations , 30
@page = ( params [ 'page' ] || 1 ) . to_i - 1
respond_to do | format |
format . html
end
@ -382,17 +408,14 @@ class AdminController < ApplicationController
#学校列表
def schools
@school_name = params [ :school_name ]
if @school_name && @school_name != ''
@schools = School . where ( " name like '% #{ @school_name } %' " )
elsif @school_name . nil?
@schools = [ ]
else @school_name && @school_name == ' '
@schools = School . where ( '1=1' )
end
@schools = School . find_by_sql ( " SELECT * FROM schools ORDER BY created_at DESC " )
@school_count = @schools . count
@school_pages = Paginator . new @school_count , 100 , params [ 'page' ] || 1
@schools = paginateHelper @schools , 100
@school_pages = Paginator . new @school_count , 30 , params [ 'page' ] || 1
@schools = paginateHelper @schools , 30
@page = ( params [ 'page' ] || 1 ) . to_i - 1
respond_to do | format |
format . html
end