Merge branch 'bigchange' of 10.0.47.245:/home/trustie2 into bigchange
This commit is contained in:
commit
33df4327b5
|
@ -10,13 +10,21 @@ class StoresController < ApplicationController
|
|||
|
||||
def search
|
||||
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.where("attachments.container_type IS NOT NULL AND filename LIKE '%" + name + "%' ").
|
||||
reorder("created_on DESC")
|
||||
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
|
||||
end
|
||||
|
||||
|
@ -32,10 +40,10 @@ class StoresController < ApplicationController
|
|||
reorder("#{Attachment.table_name}.downloads DESC").
|
||||
limit(LIMIT)
|
||||
@homeworks_attach = Attachment.where("container_type = 'HomeworkAttach'").
|
||||
reorder("created_on DESC").
|
||||
reorder("downloads DESC").
|
||||
limit(LIMIT)
|
||||
@memos_attach = Attachment.where("container_type = 'Memo'").
|
||||
reorder("created_on DESC").
|
||||
reorder("downloads DESC").
|
||||
limit(LIMIT)
|
||||
@attach_array = Array.new
|
||||
@attach_array.push(@projects_attach, @courses_attach, @homeworks_attach, @memos_attach)
|
||||
|
|
Loading…
Reference in New Issue