过滤之后现在所有的TAG云

This commit is contained in:
sw 2015-04-16 14:21:05 +08:00
parent a2b529b38b
commit 5649f4c5a1
3 changed files with 15 additions and 12 deletions

View File

@ -79,7 +79,8 @@ class FilesController < ApplicationController
@result = find_course_attache q,@course,sort @result = find_course_attache q,@course,sort
@result = visable_attachemnts @result @result = visable_attachemnts @result
@searched_attach = paginateHelper @result,10 @searched_attach = paginateHelper @result,10
@tag_list = attachment_tag_list @result
@tag_list = get_course_tag_list @course
end end
#rescue Exception => e #rescue Exception => e
# #render 'stores' # #render 'stores'
@ -541,7 +542,7 @@ class FilesController < ApplicationController
@result = visable_attachemnts @result @result = visable_attachemnts @result
@result = @result.select{|attachment| attachment.tag_list.include?(@tag_name)} @result = @result.select{|attachment| attachment.tag_list.include?(@tag_name)}
@searched_attach = paginateHelper @result,10 @searched_attach = paginateHelper @result,10
@tag_list = attachment_tag_list @result @tag_list = get_course_tag_list @course
respond_to do |format| respond_to do |format|
format.js format.js

View File

@ -223,11 +223,7 @@ class TagsController < ApplicationController
if @obj && @object_flag == '6' && @obj.container.kind_of?(Course) if @obj && @object_flag == '6' && @obj.container.kind_of?(Course)
@course = @obj.container @course = @obj.container
all_attachments = @course.attachments.select{|attachment| attachment.is_public? || @tag_list = get_course_tag_list @course
(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
end end
@ -274,11 +270,7 @@ class TagsController < ApplicationController
end end
if @obj && @obj_flag == '6' && @obj.container.kind_of?(Course) if @obj && @obj_flag == '6' && @obj.container.kind_of?(Course)
@course = @obj.container @course = @obj.container
all_attachments = @course.attachments.select{|attachment| attachment.is_public? || @tag_list = @tag_list = get_course_tag_list @course
(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
respond_to do |format| respond_to do |format|
format.js format.js

View File

@ -2106,4 +2106,14 @@ module ApplicationHelper
end end
tag_list.sort {|a,b| b[1]<=>a[1]} tag_list.sort {|a,b| b[1]<=>a[1]}
end 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 end