diff --git a/app/controllers/stores_controller.rb b/app/controllers/stores_controller.rb index ac78b5a2..8225697d 100644 --- a/app/controllers/stores_controller.rb +++ b/app/controllers/stores_controller.rb @@ -6,19 +6,24 @@ class StoresController < ApplicationController def search name = params[:name] ||= '' - redirect_to stores_path, :notice => l(:field_course_un) if name.blank? + (redirect_to stores_path, :notice => l(:label_sumbit_empty);return) if name.blank? # 按文件名搜索 - result = Attachment.where("attachments.container_type IS NOT NULL AND filename LIKE :like ", like: "%#{name}%"). + resultSet = Attachment.where("attachments.container_type IS NOT NULL AND filename LIKE :like ", like: "%#{name}%"). reorder("created_on DESC") - # result = result.to_a - result.map { |res| + + 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 ) + # logger.debug("=====================================#{result.include? res}") + # logger.debug("=====================================#{res}") result.delete(res) + # logger.debug("=====================================#{result.include? res}") end } @searched_attach = paginateHelper result diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb index 17eec739..5eb34dc9 100644 --- a/app/views/layouts/base_courses.html.erb +++ b/app/views/layouts/base_courses.html.erb @@ -77,7 +77,7 @@ <% else %> <%= join_in_course(@project, User.current) %> - <% end %> 1111 + <% end %> <% unless User.current.member_of?(@project) %>
diff --git a/app/views/layouts/base_stores.html.erb b/app/views/layouts/base_stores.html.erb index 00760263..7020f8e2 100644 --- a/app/views/layouts/base_stores.html.erb +++ b/app/views/layouts/base_stores.html.erb @@ -25,7 +25,7 @@
- + - +
<%=t(:label_course_file)%><%=t(:label_stores_index)%> <%= l(:label_user_location) %> :
<%= link_to stores_url , stores_url %>

<%=link_to l(:label_home),home_path %> > <%=link_to l(:label_course_file),stores_url %>

<%=link_to l(:label_home),home_path %> > <%=link_to l(:label_stores_index),stores_url %>

diff --git a/app/views/stores/_search_bar.html.erb b/app/views/stores/_search_bar.html.erb new file mode 100644 index 00000000..32caa11a --- /dev/null +++ b/app/views/stores/_search_bar.html.erb @@ -0,0 +1,6 @@ +
+ <%= form_tag( search_stores_path, method: 'post') do %> + <%= text_field_tag 'name', params[:name], size:"100", placeholder:'请输入要搜索的关键字', name: "name", :class => 'blueinputbar'%> + <%= submit_tag l(:label_search), :class => "enterprise"%> + <% end %> +
\ No newline at end of file diff --git a/app/views/stores/index.html.erb b/app/views/stores/index.html.erb index 5b20e5fb..4df1b823 100644 --- a/app/views/stores/index.html.erb +++ b/app/views/stores/index.html.erb @@ -1,10 +1,5 @@ <% content_for :top_field do%> -
- <%= form_tag( search_stores_path, method: 'post') do %> - <%= text_field_tag 'name', nil, size:"100", placeholder:'请输入要搜索的关键字', :class => 'blueinputbar', :required => true %> - <%= submit_tag l(:label_search), :class => "enterprise"%> - <% end %> -
+ <%= render 'search_bar' %> <% end %>
@@ -27,7 +22,7 @@ <%= link_to c1.filename, (attachFromUrl c1), {:title => c1.filename, :target => "_blank"} %> <%= c1.downloads %> - <%= link_to_attachment c1, {:text => image_tag("/images/button/download.png", width: "22px", alt: "l(:button_download)") }%> + <%= link_to_attachment c1, {:download => true, :text => image_tag("/images/button/download.png", width: "22px", alt: l(:button_download)) }%> <% end %> @@ -37,7 +32,25 @@ <% reset_cycle; end %>