|
|
|
@ -143,16 +143,19 @@ module AttachmentsHelper
|
|
|
|
|
params[:q] ||= ""
|
|
|
|
|
filename_condition = params[:q].strip
|
|
|
|
|
|
|
|
|
|
attachAll = Attachment.scoped
|
|
|
|
|
|
|
|
|
|
# 除去当前课程的所有资源
|
|
|
|
|
nobelong_attach = Attachment.where("!(container_type = '#{course.class}' and container_id = #{course.id})") unless course.blank?
|
|
|
|
|
#attachAll = Attachment.where("author_id = #{User.current.id}")
|
|
|
|
|
#
|
|
|
|
|
## 除去当前课程的所有资源
|
|
|
|
|
#nobelong_attach =
|
|
|
|
|
|
|
|
|
|
# 搜索域确定
|
|
|
|
|
domain = course.nil? ? attachAll : nobelong_attach
|
|
|
|
|
course.nil? ?
|
|
|
|
|
domain=Attachment.where("author_id = #{User.current.id}")
|
|
|
|
|
:
|
|
|
|
|
domain=Attachment.where("author_id = #{User.current.id} and container_type = 'Course' and container_id <> #{course.id}") unless course.blank?
|
|
|
|
|
|
|
|
|
|
# 搜索到的资源
|
|
|
|
|
searched_attach = domain.where("is_public=1 and filename LIKE :like ", like:"%#{filename_condition}%").limit(limit).order('created_on desc')
|
|
|
|
|
searched_attach = domain.where("filename LIKE :like ", like:"%#{filename_condition}%").limit(limit).order('created_on desc')
|
|
|
|
|
#searched_attach = private_filter searched_attach
|
|
|
|
|
searched_attach = paginateHelper(searched_attach, 10)
|
|
|
|
|
|
|
|
|
|