附件按tag查询时,只查选定项目中的附件
This commit is contained in:
parent
272be122e5
commit
7781203474
|
@ -178,7 +178,8 @@ private
|
||||||
attachments_results = nil
|
attachments_results = nil
|
||||||
@obj_pages = nil
|
@obj_pages = nil
|
||||||
@obj = nil
|
@obj = nil
|
||||||
|
@result = nil
|
||||||
|
|
||||||
# 这里为了提高系统的响应速度 把搜索结果放到case中去了
|
# 这里为了提高系统的响应速度 把搜索结果放到case中去了
|
||||||
case obj_flag
|
case obj_flag
|
||||||
when '1' then
|
when '1' then
|
||||||
|
@ -198,7 +199,11 @@ private
|
||||||
@obj_pages,@forums_results,@results_count = for_pagination(get_forums_by_tag(selected_tags))
|
@obj_pages,@forums_results,@results_count = for_pagination(get_forums_by_tag(selected_tags))
|
||||||
when '6'
|
when '6'
|
||||||
@obj = Attachment.find_by_id(obj_id)
|
@obj = Attachment.find_by_id(obj_id)
|
||||||
@obj_pages, attachments_results, @results_count = for_pagination(get_attachments_by_tag(selected_tags))
|
|
||||||
|
# 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)
|
||||||
else
|
else
|
||||||
@obj = nil
|
@obj = nil
|
||||||
end
|
end
|
||||||
|
|
|
@ -85,6 +85,22 @@ module AttachmentsHelper
|
||||||
Attachment.tagged_with(tag_name).order('created_on desc')
|
Attachment.tagged_with(tag_name).order('created_on desc')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# this method is used to get all attachments that from one project and tagged one tag
|
||||||
|
# added by Long Jun
|
||||||
|
def get_attachments_by_project_tag(tag_name, obj)
|
||||||
|
@project_id =nil
|
||||||
|
if obj.container_type == 'Version'
|
||||||
|
@project_id = Version.find(obj.container_id).project_id
|
||||||
|
|
||||||
|
elsif obj.container_type == 'Project'
|
||||||
|
@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
|
||||||
|
(container_id in (select id from versions where project_id =:project_id) and container_type = 'Version')", {:project_id => @project_id})
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
def render_attachments_for_new_project(project, limit=nil)
|
def render_attachments_for_new_project(project, limit=nil)
|
||||||
# 查询条件
|
# 查询条件
|
||||||
params[:q] ||= ""
|
params[:q] ||= ""
|
||||||
|
|
Loading…
Reference in New Issue