diff --git a/app/controllers/stores_controller.rb b/app/controllers/stores_controller.rb index f1d7e9999..b42b3a942 100644 --- a/app/controllers/stores_controller.rb +++ b/app/controllers/stores_controller.rb @@ -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)