From 5649f4c5a166afac906ca5b5b1b2eefdf0635b6a Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 16 Apr 2015 14:21:05 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=87=E6=BB=A4=E4=B9=8B=E5=90=8E=E7=8E=B0?= =?UTF-8?q?=E5=9C=A8=E6=89=80=E6=9C=89=E7=9A=84TAG=E4=BA=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/files_controller.rb | 5 +++-- app/controllers/tags_controller.rb | 12 ++---------- app/helpers/application_helper.rb | 10 ++++++++++ 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index 1e51d7dd2..8b1c8ba32 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -79,7 +79,8 @@ class FilesController < ApplicationController @result = find_course_attache q,@course,sort @result = visable_attachemnts @result @searched_attach = paginateHelper @result,10 - @tag_list = attachment_tag_list @result + + @tag_list = get_course_tag_list @course end #rescue Exception => e # #render 'stores' @@ -541,7 +542,7 @@ class FilesController < ApplicationController @result = visable_attachemnts @result @result = @result.select{|attachment| attachment.tag_list.include?(@tag_name)} @searched_attach = paginateHelper @result,10 - @tag_list = attachment_tag_list @result + @tag_list = get_course_tag_list @course respond_to do |format| format.js diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index d4399e464..f1c9451bf 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -223,11 +223,7 @@ class TagsController < ApplicationController if @obj && @object_flag == '6' && @obj.container.kind_of?(Course) @course = @obj.container - all_attachments = @course.attachments.select{|attachment| attachment.is_public? || - (attachment.container_type == "Course" && User.current.member_of_course?(@course))|| - attachment.author_id == User.current.id - } - @tag_list = attachment_tag_list all_attachments + @tag_list = get_course_tag_list @course end # end end @@ -274,11 +270,7 @@ class TagsController < ApplicationController end if @obj && @obj_flag == '6' && @obj.container.kind_of?(Course) @course = @obj.container - all_attachments = @course.attachments.select{|attachment| attachment.is_public? || - (attachment.container_type == "Course" && User.current.member_of_course?(@course))|| - attachment.author_id == User.current.id - } - @tag_list = attachment_tag_list all_attachments + @tag_list = @tag_list = get_course_tag_list @course end respond_to do |format| format.js diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 5782d4bc8..9c9c96ce5 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -2106,4 +2106,14 @@ module ApplicationHelper end tag_list.sort {|a,b| b[1]<=>a[1]} end + + #获取课程资源的TAG云 + def get_course_tag_list course + all_attachments = course.attachments.select{|attachment| attachment.is_public? || + (attachment.container_type == "Course" && User.current.member_of_course?(course))|| + attachment.author_id == User.current.id + } + tag_list = attachment_tag_list all_attachments + tag_list + end end