#1149 资源搜索:平台提示说不会搜索私有项目中的内容,实际上却可搜索得到私有项目中文件资源

This commit is contained in:
z9hang 2014-12-02 17:06:17 +08:00
parent d8e9dba404
commit e788cd9a0f
1 changed files with 12 additions and 12 deletions

View File

@ -26,19 +26,19 @@ class StoresController < ApplicationController
resultSet = Attachment.where("attachments.container_type IS NOT NULL AND filename LIKE :like ", like: "%#{keywords}%").
reorder("created_on DESC")
# result = resultSet.to_a.dup
result = resultSet.to_a.dup
# resultSet.to_a.map { |res|
# if(res.container.nil? ||
# (res.container.class.to_s=="Project" && res.container.is_public == false) ||
# (res.container.has_attribute?(:project) && res.container.project.is_public == false) ||
# (res.container.class.to_s=="HomeworkAttach" && res.container.bid.reward_type == 3) ||
# false
# )
# result.delete(res)
# end
# }
# result
resultSet.to_a.map { |res|
if(res.container.nil? ||
(res.container.class.to_s=="Project" && res.container.is_public == false) ||
(res.container.has_attribute?(:project) && res.container.project.is_public == false) ||
(res.container.class.to_s=="HomeworkAttach" && res.container.bid.reward_type == 3) ||
false
) || (res.container.is_a?(Course) && res.container.is_public == 0)
result.delete(res)
end
}
result
end
LIMIT = 12 unless const_defined?(:LIMIT)