From 3a48034fcaa6f1c69fe3bf9427c3ac50cf4d5801 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Wed, 22 Oct 2014 10:50:41 +0800 Subject: [PATCH] =?UTF-8?q?#1387=E4=BF=AE=E5=A4=8D=E8=AF=BE=E7=A8=8B--?= =?UTF-8?q?=E8=B5=84=E6=BA=90=E5=BA=93-=E5=85=B3=E8=81=94=E8=B5=84?= =?UTF-8?q?=E6=BA=90=E6=9F=A5=E8=AF=A2=E5=87=BA=E6=9D=A5=E7=9A=84=E7=BB=93?= =?UTF-8?q?=E6=9E=9C=E6=98=AF=E6=95=B4=E4=B8=AA=E9=A1=B9=E7=9B=AE=E4=B8=AD?= =?UTF-8?q?=E8=B5=84=E6=BA=90=E7=9A=84=E9=9B=86=E5=90=88=E7=9A=84BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/attachments_helper.rb | 15 +++++++++------ app/views/files/_course_new.html.erb | 7 ++++--- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/app/helpers/attachments_helper.rb b/app/helpers/attachments_helper.rb index e6f20ea60..060ced940 100644 --- a/app/helpers/attachments_helper.rb +++ b/app/helpers/attachments_helper.rb @@ -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) diff --git a/app/views/files/_course_new.html.erb b/app/views/files/_course_new.html.erb index 88c33d865..2eaa70cb6 100644 --- a/app/views/files/_course_new.html.erb +++ b/app/views/files/_course_new.html.erb @@ -1,4 +1,6 @@ -