This commit is contained in:
parent
3f54d24e52
commit
ee570ea0ac
|
@ -10,13 +10,21 @@ class StoresController < ApplicationController
|
||||||
|
|
||||||
def search
|
def search
|
||||||
name = params[:name] ||= ''
|
name = params[:name] ||= ''
|
||||||
redirect_to stores_path, :notice => '为何不写点东西?' if name.blank?
|
redirect_to stores_path, :notice => l(:field_course_un) if name.blank?
|
||||||
# 按文件名搜索
|
# 按文件名搜索
|
||||||
#result = Attachment.includes(:project).where("projects.is_public = 1 AND filename LIKE '%" << name << "%' ")
|
#result = Attachment.includes(:project).where("projects.is_public = 1 AND filename LIKE '%" << name << "%' ")
|
||||||
result = Attachment.where("attachments.container_type IS NOT NULL AND filename LIKE '%" + name + "%' ").
|
result = Attachment.where("attachments.container_type IS NOT NULL AND filename LIKE '%" + name + "%' ").
|
||||||
reorder("created_on DESC")
|
reorder("created_on DESC")
|
||||||
result = result.to_a
|
result = result.to_a
|
||||||
result.map { |res| result.delete(res) if res.container.nil?}
|
result.map { |res|
|
||||||
|
if(res.container.nil? ||
|
||||||
|
(res.container.class.to_s.eql?("Project") && res.container.is_public == false) ||
|
||||||
|
(res.container.class.to_s.eql?("HomeworkAttach") && res.container.bid.reward_type == 3) ||
|
||||||
|
false
|
||||||
|
)
|
||||||
|
result.delete(res)
|
||||||
|
end
|
||||||
|
}
|
||||||
@searched_attach = paginateHelper result
|
@searched_attach = paginateHelper result
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -32,10 +40,10 @@ class StoresController < ApplicationController
|
||||||
reorder("#{Attachment.table_name}.downloads DESC").
|
reorder("#{Attachment.table_name}.downloads DESC").
|
||||||
limit(LIMIT)
|
limit(LIMIT)
|
||||||
@homeworks_attach = Attachment.where("container_type = 'HomeworkAttach'").
|
@homeworks_attach = Attachment.where("container_type = 'HomeworkAttach'").
|
||||||
reorder("created_on DESC").
|
reorder("downloads DESC").
|
||||||
limit(LIMIT)
|
limit(LIMIT)
|
||||||
@memos_attach = Attachment.where("container_type = 'Memo'").
|
@memos_attach = Attachment.where("container_type = 'Memo'").
|
||||||
reorder("created_on DESC").
|
reorder("downloads DESC").
|
||||||
limit(LIMIT)
|
limit(LIMIT)
|
||||||
@attach_array = Array.new
|
@attach_array = Array.new
|
||||||
@attach_array.push(@projects_attach, @courses_attach, @homeworks_attach, @memos_attach)
|
@attach_array.push(@projects_attach, @courses_attach, @homeworks_attach, @memos_attach)
|
||||||
|
|
Loading…
Reference in New Issue