全站搜索不在搜索非本人的私有资源,且他人的公开资源亦不能修改其公开私有属性2、添加迁移文件

This commit is contained in:
z9hang 2014-11-21 14:57:10 +08:00
parent 75ebfb4a9e
commit cf808598d2
3 changed files with 8 additions and 2 deletions

View File

@ -69,7 +69,7 @@ class FilesController < ApplicationController
# StoresController#search 将每条文件都查出来,再次进行判断过滤。---> resultSet.to_a.map
# 此时内容不多速度还可但文件增长每条判断多则进行3-4次表连接。
# 现在还木有思路 药丸
resultSet = Attachment.where("attachments.container_type IS NOT NULL AND filename LIKE :like ", like: "%#{keywords}%").
resultSet = Attachment.where("attachments.container_type IS NOT NULL AND (is_public = 1 OR author_id = #{User.current.id}) AND filename LIKE :like ", like: "%#{keywords}%").
reorder("created_on DESC")
end

View File

@ -21,12 +21,13 @@
<div class="re_con_box">
<div class=" ">
<%= link_to_attachment file, :download => true, :title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "c_dblue f_14 f_b f_l" %>
<% if is_course_teacher(User.current,@course) %>
<% if is_course_teacher(User.current,@course) && User.current.id == file.author_id %>
<%= link_to "选入我的课程",quote_resource_show_course_file_path(@course,file),:class => "f_l re_select",:remote => true %>
<span id="is_public_<%= file.id %>">
<%= link_to (file.is_public? ? "公开":"私有"), update_file_dense_attachments_path(:attachmentid=>file.id,:newtype=>(file.is_public? ? 0:1)),:remote=>true,:class=>"f_l re_open",:method => :post %>
</span>
<% else %>
<%= link_to "选入我的课程",quote_resource_show_course_file_path(@course,file),:class => "f_l re_select",:remote => true %>
<%= link_to (file.is_public? ? "公开":"私有"),"javascript:void(0)",:class=>"f_l re_open" %>
<% end %>
</div>

View File

@ -0,0 +1,5 @@
class AddColumnCopyfromToAttachment < ActiveRecord::Migration
def change
add_column("attachments","copy_from",:integer)
end
end