From 8b80d99a7093595f8e98006e7e37e6646d1cde41 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 31 Jul 2014 14:39:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=B5=84=E6=BA=90=E6=A0=87?= =?UTF-8?q?=E8=AE=B0=E6=90=9C=E7=B4=A2=E4=B8=8D=E6=AD=A3=E7=A1=AE=E7=9A=84?= =?UTF-8?q?BUG=20issues#1089?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/tags_controller.rb | 23 ++++++++++++----------- app/helpers/attachments_helper.rb | 3 ++- app/views/tags/_show_attachments.html.erb | 2 +- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index ba01aa990..1318e40a5 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -71,8 +71,8 @@ class TagsController < ApplicationController @projects_results, @issues_results, @bids_results, - @forums_results, - attachments_results, + @forums_results, + @attachments_results, @contests_results, @courses_results, @open_source_projects_results= refresh_results(@obj_id,@obj_flag,@selected_tags) @@ -107,8 +107,8 @@ class TagsController < ApplicationController @projects_results, @issues_results, @bids_results, - @forums_results, - attachments_results, + @forums_results, + @attachments_results, @contests_results, @courses_results, @open_source_projects_results= refresh_results(@obj_id,@show_flag) @@ -130,8 +130,8 @@ class TagsController < ApplicationController @projects_results, @issues_results, @bids_results, - @forums_results, - attachments_results, + @forums_results, + @attachments_results, @contests_results, @courses_results, @open_source_projects_results= refresh_results(@obj_id,@show_flag) @@ -199,7 +199,7 @@ class TagsController < ApplicationController @bids_results = nil @contests_results = nil @forums_results = nil - attachments_results = nil + @attachments_results = nil @open_source_projects_results = nil @obj_pages = nil @obj = nil @@ -228,8 +228,9 @@ class TagsController < ApplicationController # modifed by Long Jun # this is used to find the attachments that came from the same project and tagged with the same tag. - @result = get_attachments_by_project_tag(selected_tags, @obj) - @obj_pages, attachments_results, @results_count = for_pagination(@result) + #@result = get_attachments_by_project_tag(selected_tags, @obj) + @result = get_attachments_by_tag(selected_tags) + @obj_pages, @attachments_results, @results_count = for_pagination(@result) when '7' @obj = Contest.find_by_id(obj_id) @obj_pages,@contests_results,@results_count = for_pagination(get_contests_by_tag(selected_tags)) @@ -249,8 +250,8 @@ class TagsController < ApplicationController @projects_results, @issues_results, @bids_results, - @forums_results, - attachments_results, + @forums_results, + @attachments_results, @contests_results, @courses_results, @open_source_projects_results] diff --git a/app/helpers/attachments_helper.rb b/app/helpers/attachments_helper.rb index b43eb22f1..ee9d2a70d 100644 --- a/app/helpers/attachments_helper.rb +++ b/app/helpers/attachments_helper.rb @@ -87,8 +87,9 @@ module AttachmentsHelper @project_id = obj.container_id end - Attachment.tagged_with(tag_name).order('created_on desc').where("(container_id = :project_id and container_type = 'Project') or + attachments = Attachment.tagged_with(tag_name).order('created_on desc').where("(container_id = :project_id and container_type = 'Project') or (container_id in (select id from versions where project_id =:project_id) and container_type = 'Version')", {:project_id => @project_id}) + return attachments end diff --git a/app/views/tags/_show_attachments.html.erb b/app/views/tags/_show_attachments.html.erb index 43ed76e02..8b0bb1f8b 100644 --- a/app/views/tags/_show_attachments.html.erb +++ b/app/views/tags/_show_attachments.html.erb @@ -1,5 +1,5 @@
-<% if attachments_results.try(:size).to_i < 0 %> +<% if attachments_results.nil? || attachments_results.try(:size).to_i < 0 %> <% else %>
<% attachments_results.each do |file| %>