diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index e26901320..d4399e464 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -220,6 +220,15 @@ class TagsController < ApplicationController @tag = ActsAsTaggableOn::Tag.find_by_id(@tag_id) @tag.delete unless @tag.nil? end + + 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 + end # end end end @@ -263,6 +272,14 @@ class TagsController < ApplicationController else logger.error "#{__FILE__}:#{__LINE__} ===> #{@obj.errors.try(:full_messages)}" 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 + end respond_to do |format| format.js format.html diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 095d0ada5..5782d4bc8 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -2097,4 +2097,13 @@ module ApplicationHelper request.env["HTTP_USER_AGENT"] =~ /MSIE 8.0/ end + + #获取指定资源列表的TAG的集合以及每个TAG的数量,降序排序 + def attachment_tag_list attachments + tag_list = Hash.new + attachments.each do |attachment| + attachment.tag_list.map{|tag| tag_list.has_key?(tag) ? tag_list[tag] = tag_list[tag] + 1 : tag_list[tag] = 1} + end + tag_list.sort {|a,b| b[1]<=>a[1]} + end end diff --git a/app/helpers/files_helper.rb b/app/helpers/files_helper.rb index 0be59c0da..d69f13a29 100644 --- a/app/helpers/files_helper.rb +++ b/app/helpers/files_helper.rb @@ -120,14 +120,6 @@ module FilesHelper result end - def attachment_tag_list attachments - tag_list = Hash.new - attachments.each do |attachment| - attachment.tag_list.map{|tag| tag_list.has_key?(tag) ? tag_list[tag] = tag_list[tag] + 1 : tag_list[tag] = 1} - end - tag_list.sort {|a,b| b[1]<=>a[1]} - end - def get_attachments_by_tag attachments,tag attachments.each do |attachment| attachment.tag_list.include?(tag) diff --git a/app/views/files/_course_list.html.erb b/app/views/files/_course_list.html.erb index 5bbb8757d..c726d63e7 100644 --- a/app/views/files/_course_list.html.erb +++ b/app/views/files/_course_list.html.erb @@ -15,12 +15,8 @@
-