点击tag之后的索引功能.

This commit is contained in:
yanxd 2013-11-30 10:46:32 +08:00
parent 344e51105a
commit 825b1e7fd7
9 changed files with 174 additions and 134 deletions

View File

@ -8,6 +8,7 @@ class TagsController < ApplicationController
include IssuesHelper
include UsersHelper
include BidsHelper
include ForumsHelper
include ActsAsTaggableOn::TagsHelper
helper :projects
include TagsHelper
@ -56,7 +57,8 @@ class TagsController < ApplicationController
@obj,@obj_pages,@results_count,@users_results,
@projects_results,
@issues_results,
@bids_results = refresh_results(@obj_id,@obj_flag,@selected_tags)
@bids_results,
@forums_results = refresh_results(@obj_id,@obj_flag,@selected_tags)
# 这里是做tag推荐用的 用来生产推荐的tags
unless @obj.nil?
@ -83,7 +85,8 @@ class TagsController < ApplicationController
@obj,@obj_pages,@users_results,
@projects_results,
@issues_results,
@bids_results = refresh_results(@obj_id,@show_flag)
@bids_results,
@forums_results = refresh_results(@obj_id,@show_flag)
end
# 删除已选tag
@ -98,7 +101,8 @@ class TagsController < ApplicationController
@obj,@obj_pages,@results_count,@users_results,
@projects_results,
@issues_results,
@bids_results = refresh_results(@obj_id,@show_flag)
@bids_results,
@forums_results = refresh_results(@obj_id,@show_flag)
end
def show_all
@ -161,6 +165,7 @@ private
@projects_results = nil
@issues_results = nil
@bids_results = nil
@forums_results = nil
@obj_pages = nil
@obj = nil
@ -176,12 +181,15 @@ private
@obj = Issue.find_by_id(obj_id)
@obj_pages,@issues_results,@results_count = for_pagination(get_issues_by_tag(selected_tags))
when '4' then
@obj_pages,@bids_results,@results_count = for_pagination(get_bids_by_tag(selected_tags))
@obj = Bid.find_by_id(obj_id)
@obj_pages,@bids_results,@results_count = for_pagination(get_bids_by_tag(selected_tags))
@obj = Bid.find_by_id(obj_id)
when '5'
@obj = Forum.find_by_id(obj_id)
@obj_pages,@forums_results,@results_count = for_pagination(get_forums_by_tag(selected_tags))
else
@obj = nil
end
return @obj,@obj_pages,@results_count,@users_results,@projects_results,@issues_results,@bids_results
return @obj,@obj_pages,@results_count,@users_results,@projects_results,@issues_results,@bids_results,@forums_results
end
def for_pagination(results)

View File

@ -19,4 +19,10 @@ module ForumsHelper
end
options
end
# this method is used to get all projects that tagged one tag
# added by william
def get_forums_by_tag(tag_name)
Forum.tagged_with(tag_name).order('updated_at desc')
end
end

View File

@ -0,0 +1,15 @@
<div id="issues">
<% if forums_results.size > 0 %>
<hr />
<% forums_results.each do |forum| %>
<p class="font_description2">
<strong><%= l(:label_tags_forum) %>:<%= link_to "#{forum.name}",
:controller => "forums",:action => "show",:id => forum.id %></strong>
<br />
<strong><%= l(:label_tags_forum_description) %>:</strong><%= forum.description %>
<%= forum.updated_at %>
</p>
<div class="line_under"></div>
<% end %>
<% end %>
</div>

View File

@ -7,4 +7,6 @@
(<%= Issue.tagged_with("#{sg}").size %>)
<% when '4' then %>
(<%= Bid.tagged_with("#{sg}").size %>)
<% when '5' then %>
(<%= Forum.tagged_with("#{sg}").size %>)
<% end %>

View File

@ -13,6 +13,9 @@
<% when show_flag == '4'%>
<strong><%= l(:label_requirement)%>(<%= @results_count %>)</strong>
<%= render :partial => "show_bids",:locals => {:bids_results => bids_results}%>
<% when show_flag == '5'%>
<strong><%= l(:label_forum)%>(<%= @results_count %>)</strong>
<%= render :partial => "show_forums",:locals => {:forums_results => forums_results}%>
<% else %>
<strong><%= l(:label_tags_all_objects)%></strong>
<!-- 这里为显示搜有过滤结果预留了默认设置 -->

View File

@ -26,7 +26,7 @@
<div id="show_results">
<%= render :partial => "tag_search_results",:locals => {:issues_results => @issues_results,
:projects_results => @projects_results,:users_results => @users_results ,
:bids_results=>@bids_results,:show_flag => @obj_flag}%>
:bids_results=>@bids_results,:forums_results => @forums_results, :show_flag => @obj_flag}%>
</div>
</div>

View File

@ -1571,6 +1571,9 @@ en:
label_memo_new: new memo
label_memo_edit: edit memo
label_project_module_forums: Forums
label_forum: Forum
label_tags_forum_description: Forum description
label_tags_forum: Call forum

View File

@ -1735,3 +1735,6 @@ zh:
label_borad_project: 项目讨论区
label_borad_course: 课程讨论区
label_memo_new_from_forum: 发布帖子
label_forum: 讨论区
label_tags_forum_description: 讨论区描述
label_tags_forum: 讨论区名称