点击tag之后的索引功能.
This commit is contained in:
parent
344e51105a
commit
825b1e7fd7
|
@ -8,6 +8,7 @@ class TagsController < ApplicationController
|
||||||
include IssuesHelper
|
include IssuesHelper
|
||||||
include UsersHelper
|
include UsersHelper
|
||||||
include BidsHelper
|
include BidsHelper
|
||||||
|
include ForumsHelper
|
||||||
include ActsAsTaggableOn::TagsHelper
|
include ActsAsTaggableOn::TagsHelper
|
||||||
helper :projects
|
helper :projects
|
||||||
include TagsHelper
|
include TagsHelper
|
||||||
|
@ -56,7 +57,8 @@ class TagsController < ApplicationController
|
||||||
@obj,@obj_pages,@results_count,@users_results,
|
@obj,@obj_pages,@results_count,@users_results,
|
||||||
@projects_results,
|
@projects_results,
|
||||||
@issues_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
|
# 这里是做tag推荐用的, 用来生产推荐的tags
|
||||||
unless @obj.nil?
|
unless @obj.nil?
|
||||||
|
@ -83,7 +85,8 @@ class TagsController < ApplicationController
|
||||||
@obj,@obj_pages,@users_results,
|
@obj,@obj_pages,@users_results,
|
||||||
@projects_results,
|
@projects_results,
|
||||||
@issues_results,
|
@issues_results,
|
||||||
@bids_results = refresh_results(@obj_id,@show_flag)
|
@bids_results,
|
||||||
|
@forums_results = refresh_results(@obj_id,@show_flag)
|
||||||
end
|
end
|
||||||
|
|
||||||
# 删除已选tag
|
# 删除已选tag
|
||||||
|
@ -98,7 +101,8 @@ class TagsController < ApplicationController
|
||||||
@obj,@obj_pages,@results_count,@users_results,
|
@obj,@obj_pages,@results_count,@users_results,
|
||||||
@projects_results,
|
@projects_results,
|
||||||
@issues_results,
|
@issues_results,
|
||||||
@bids_results = refresh_results(@obj_id,@show_flag)
|
@bids_results,
|
||||||
|
@forums_results = refresh_results(@obj_id,@show_flag)
|
||||||
end
|
end
|
||||||
|
|
||||||
def show_all
|
def show_all
|
||||||
|
@ -161,6 +165,7 @@ private
|
||||||
@projects_results = nil
|
@projects_results = nil
|
||||||
@issues_results = nil
|
@issues_results = nil
|
||||||
@bids_results = nil
|
@bids_results = nil
|
||||||
|
@forums_results = nil
|
||||||
@obj_pages = nil
|
@obj_pages = nil
|
||||||
@obj = nil
|
@obj = nil
|
||||||
|
|
||||||
|
@ -176,12 +181,15 @@ private
|
||||||
@obj = Issue.find_by_id(obj_id)
|
@obj = Issue.find_by_id(obj_id)
|
||||||
@obj_pages,@issues_results,@results_count = for_pagination(get_issues_by_tag(selected_tags))
|
@obj_pages,@issues_results,@results_count = for_pagination(get_issues_by_tag(selected_tags))
|
||||||
when '4' then
|
when '4' then
|
||||||
@obj_pages,@bids_results,@results_count = for_pagination(get_bids_by_tag(selected_tags))
|
@obj_pages,@bids_results,@results_count = for_pagination(get_bids_by_tag(selected_tags))
|
||||||
@obj = Bid.find_by_id(obj_id)
|
@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
|
else
|
||||||
@obj = nil
|
@obj = nil
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
def for_pagination(results)
|
def for_pagination(results)
|
||||||
|
|
|
@ -1,128 +1,128 @@
|
||||||
#enconding:utf-8
|
#enconding:utf-8
|
||||||
# fq
|
# fq
|
||||||
module BidsHelper
|
module BidsHelper
|
||||||
|
|
||||||
def render_notes(bid, journal, options={})
|
def render_notes(bid, journal, options={})
|
||||||
content = ''
|
content = ''
|
||||||
removable = User.current == journal.user || User.current == bid.author
|
removable = User.current == journal.user || User.current == bid.author
|
||||||
links = []
|
links = []
|
||||||
if !journal.notes.blank?
|
if !journal.notes.blank?
|
||||||
links << link_to(image_tag('comment.png'),
|
links << link_to(image_tag('comment.png'),
|
||||||
{:controller => 'bids', :action => 'new', :id => bid, :journal_id => journal},
|
{:controller => 'bids', :action => 'new', :id => bid, :journal_id => journal},
|
||||||
:remote => true,
|
:remote => true,
|
||||||
:method => 'post',
|
:method => 'post',
|
||||||
:title => l(:button_quote)) if options[:reply_links]
|
:title => l(:button_quote)) if options[:reply_links]
|
||||||
if removable
|
if removable
|
||||||
url = {:controller => 'bids',
|
url = {:controller => 'bids',
|
||||||
:action => 'destroy',
|
:action => 'destroy',
|
||||||
:object_id => journal,
|
:object_id => journal,
|
||||||
:id => bid}
|
:id => bid}
|
||||||
links << ' '
|
links << ' '
|
||||||
links << link_to(image_tag('delete.png'), url,
|
links << link_to(image_tag('delete.png'), url,
|
||||||
:remote => true, :method => 'delete', :class => "delete", :title => l(:button_delete))
|
:remote => true, :method => 'delete', :class => "delete", :title => l(:button_delete))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
content << content_tag('div', links.join(' ').html_safe, :class => 'contextual') unless links.empty?
|
content << content_tag('div', links.join(' ').html_safe, :class => 'contextual') unless links.empty?
|
||||||
content << textilizable(journal.notes)
|
content << textilizable(journal.notes)
|
||||||
css_classes = "wiki"
|
css_classes = "wiki"
|
||||||
content_tag('div', content.html_safe, :id => "journal-#{journal.id}-notes", :class => css_classes)
|
content_tag('div', content.html_safe, :id => "journal-#{journal.id}-notes", :class => css_classes)
|
||||||
end
|
end
|
||||||
|
|
||||||
def link_to_in_place_notes_editor(text, field_id, url, options={})
|
def link_to_in_place_notes_editor(text, field_id, url, options={})
|
||||||
onclick = "$.ajax({url: '#{url_for(url)}', type: 'get'}); return false;"
|
onclick = "$.ajax({url: '#{url_for(url)}', type: 'get'}); return false;"
|
||||||
link_to text, '#', options.merge(:onclick => onclick)
|
link_to text, '#', options.merge(:onclick => onclick)
|
||||||
end
|
end
|
||||||
|
|
||||||
# this method is used to get all projects that tagged one tag
|
# this method is used to get all projects that tagged one tag
|
||||||
# added by william
|
# added by william
|
||||||
def get_bids_by_tag(tag_name)
|
def get_bids_by_tag(tag_name)
|
||||||
Bid.tagged_with(tag_name).order('updated_on desc')
|
Bid.tagged_with(tag_name).order('updated_on desc')
|
||||||
end
|
end
|
||||||
|
|
||||||
#added by huang
|
#added by huang
|
||||||
def sort_bid_enterprise(state, project_type)
|
def sort_bid_enterprise(state, project_type)
|
||||||
content = ''.html_safe
|
content = ''.html_safe
|
||||||
case state
|
case state
|
||||||
when 0
|
when 0
|
||||||
content << content_tag('li', link_to(l(:label_sort_by_active), calls_path(:bid_sort_type => '1', :project_type => project_type)))
|
content << content_tag('li', link_to(l(:label_sort_by_active), calls_path(:bid_sort_type => '1', :project_type => project_type)))
|
||||||
content << content_tag('li', link_to(l(:label_sort_by_time), calls_path(:bid_sort_type => '0', :project_type => project_type), :class=>"selected"), :class=>"selected")
|
content << content_tag('li', link_to(l(:label_sort_by_time), calls_path(:bid_sort_type => '0', :project_type => project_type), :class=>"selected"), :class=>"selected")
|
||||||
|
|
||||||
when 1
|
when 1
|
||||||
content << content_tag('li', link_to(l(:label_sort_by_active), calls_path(:bid_sort_type => '1', :project_type => project_type), :class=>"selected"), :class=>"selected")
|
content << content_tag('li', link_to(l(:label_sort_by_active), calls_path(:bid_sort_type => '1', :project_type => project_type), :class=>"selected"), :class=>"selected")
|
||||||
content << content_tag('li', link_to(l(:label_sort_by_time), calls_path(:bid_sort_type => '0', :project_type => project_type)))
|
content << content_tag('li', link_to(l(:label_sort_by_time), calls_path(:bid_sort_type => '0', :project_type => project_type)))
|
||||||
end
|
end
|
||||||
content = content_tag('ul', content)
|
content = content_tag('ul', content)
|
||||||
content_tag('div', content, :class => "tabs_enterprise")
|
content_tag('div', content, :class => "tabs_enterprise")
|
||||||
end
|
end
|
||||||
#end
|
#end
|
||||||
|
|
||||||
def sort_bid(state, project_type)
|
def sort_bid(state, project_type)
|
||||||
content = ''.html_safe
|
content = ''.html_safe
|
||||||
case state
|
case state
|
||||||
when 0
|
when 0
|
||||||
content << content_tag('li', link_to(l(:label_sort_by_active), calls_path(:bid_sort_type => '1', :project_type => project_type)))
|
content << content_tag('li', link_to(l(:label_sort_by_active), calls_path(:bid_sort_type => '1', :project_type => project_type)))
|
||||||
content << content_tag('li', link_to(l(:label_sort_by_time), calls_path(:bid_sort_type => '0', :project_type => project_type), :class=>"selected"), :class=>"selected")
|
content << content_tag('li', link_to(l(:label_sort_by_time), calls_path(:bid_sort_type => '0', :project_type => project_type), :class=>"selected"), :class=>"selected")
|
||||||
|
|
||||||
when 1
|
when 1
|
||||||
content << content_tag('li', link_to(l(:label_sort_by_active), calls_path(:bid_sort_type => '1', :project_type => project_type), :class=>"selected"), :class=>"selected")
|
content << content_tag('li', link_to(l(:label_sort_by_active), calls_path(:bid_sort_type => '1', :project_type => project_type), :class=>"selected"), :class=>"selected")
|
||||||
content << content_tag('li', link_to(l(:label_sort_by_time), calls_path(:bid_sort_type => '0', :project_type => project_type)))
|
content << content_tag('li', link_to(l(:label_sort_by_time), calls_path(:bid_sort_type => '0', :project_type => project_type)))
|
||||||
end
|
end
|
||||||
content = content_tag('ul', content)
|
content = content_tag('ul', content)
|
||||||
content_tag('div', content, :class => "tabs")
|
content_tag('div', content, :class => "tabs")
|
||||||
end
|
end
|
||||||
|
|
||||||
#huang
|
#huang
|
||||||
def sort_contest(state)
|
def sort_contest(state)
|
||||||
content = ''.html_safe
|
content = ''.html_safe
|
||||||
case state
|
case state
|
||||||
when 0
|
when 0
|
||||||
content << content_tag('li', link_to(l(:label_sort_by_active), contest_path(:contest_sort_type => '1')))
|
content << content_tag('li', link_to(l(:label_sort_by_active), contest_path(:contest_sort_type => '1')))
|
||||||
content << content_tag('li', link_to(l(:label_sort_by_time), contest_path(:contest_sort_type => '0'), :class=>"selected"), :class=>"selected")
|
content << content_tag('li', link_to(l(:label_sort_by_time), contest_path(:contest_sort_type => '0'), :class=>"selected"), :class=>"selected")
|
||||||
|
|
||||||
when 1
|
when 1
|
||||||
content << content_tag('li', link_to(l(:label_sort_by_active), contest_path(:contest_sort_type => '1'), :class=>"selected"), :class=>"selected")
|
content << content_tag('li', link_to(l(:label_sort_by_active), contest_path(:contest_sort_type => '1'), :class=>"selected"), :class=>"selected")
|
||||||
content << content_tag('li', link_to(l(:label_sort_by_time), contest_path(:contest_sort_type => '0')))
|
content << content_tag('li', link_to(l(:label_sort_by_time), contest_path(:contest_sort_type => '0')))
|
||||||
end
|
end
|
||||||
content = content_tag('ul', content)
|
content = content_tag('ul', content)
|
||||||
content_tag('div', content, :class => "tabs")
|
content_tag('div', content, :class => "tabs")
|
||||||
end
|
end
|
||||||
#end
|
#end
|
||||||
|
|
||||||
def course_options_for_select(courses)
|
def course_options_for_select(courses)
|
||||||
# <option value = '0'>#{l(:label_choose_reward)}</option>
|
# <option value = '0'>#{l(:label_choose_reward)}</option>
|
||||||
html = ''
|
html = ''
|
||||||
courses.each do |course|
|
courses.each do |course|
|
||||||
html << "<option value = #{course.id}>"
|
html << "<option value = #{course.id}>"
|
||||||
html << course.name
|
html << course.name
|
||||||
html << "</option>"
|
html << "</option>"
|
||||||
end
|
end
|
||||||
html.html_safe
|
html.html_safe
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
# used to get the reward and handle the value which can be used to display in views
|
# used to get the reward and handle the value which can be used to display in views
|
||||||
# added by william
|
# added by william
|
||||||
def get_prize(b_project)
|
def get_prize(b_project)
|
||||||
b_project.get_reward
|
b_project.get_reward
|
||||||
end
|
end
|
||||||
|
|
||||||
def count_bid_project
|
def count_bid_project
|
||||||
bids = Bid.where('parent_id = ?', @bid.id)
|
bids = Bid.where('parent_id = ?', @bid.id)
|
||||||
@projects = []
|
@projects = []
|
||||||
for bid in bids
|
for bid in bids
|
||||||
@projects += bid.biding_projects
|
@projects += bid.biding_projects
|
||||||
end
|
end
|
||||||
@projects.count
|
@projects.count
|
||||||
end
|
end
|
||||||
|
|
||||||
def count_bid_user
|
def count_bid_user
|
||||||
bids = Bid.where('parent_id = ?', @bid.id)
|
bids = Bid.where('parent_id = ?', @bid.id)
|
||||||
@users = []
|
@users = []
|
||||||
for bid in bids
|
for bid in bids
|
||||||
for project in bid.projects
|
for project in bid.projects
|
||||||
@users += project.users
|
@users += project.users
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@users.count
|
@users.count
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -19,4 +19,10 @@ module ForumsHelper
|
||||||
end
|
end
|
||||||
options
|
options
|
||||||
end
|
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
|
end
|
||||||
|
|
|
@ -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>
|
|
@ -7,4 +7,6 @@
|
||||||
(<%= Issue.tagged_with("#{sg}").size %>)
|
(<%= Issue.tagged_with("#{sg}").size %>)
|
||||||
<% when '4' then %>
|
<% when '4' then %>
|
||||||
(<%= Bid.tagged_with("#{sg}").size %>)
|
(<%= Bid.tagged_with("#{sg}").size %>)
|
||||||
|
<% when '5' then %>
|
||||||
|
(<%= Forum.tagged_with("#{sg}").size %>)
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -13,6 +13,9 @@
|
||||||
<% when show_flag == '4'%>
|
<% when show_flag == '4'%>
|
||||||
<strong><%= l(:label_requirement)%>(<%= @results_count %>)</strong>
|
<strong><%= l(:label_requirement)%>(<%= @results_count %>)</strong>
|
||||||
<%= render :partial => "show_bids",:locals => {:bids_results => bids_results}%>
|
<%= 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 %>
|
<% else %>
|
||||||
<strong><%= l(:label_tags_all_objects)%></strong>
|
<strong><%= l(:label_tags_all_objects)%></strong>
|
||||||
<!-- 这里为显示搜有过滤结果预留了默认设置 -->
|
<!-- 这里为显示搜有过滤结果预留了默认设置 -->
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
<div id="show_results">
|
<div id="show_results">
|
||||||
<%= render :partial => "tag_search_results",:locals => {:issues_results => @issues_results,
|
<%= render :partial => "tag_search_results",:locals => {:issues_results => @issues_results,
|
||||||
:projects_results => @projects_results,:users_results => @users_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>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1571,6 +1571,9 @@ en:
|
||||||
label_memo_new: new memo
|
label_memo_new: new memo
|
||||||
label_memo_edit: edit memo
|
label_memo_edit: edit memo
|
||||||
label_project_module_forums: Forums
|
label_project_module_forums: Forums
|
||||||
|
label_forum: Forum
|
||||||
|
label_tags_forum_description: Forum description
|
||||||
|
label_tags_forum: Call forum
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1735,3 +1735,6 @@ zh:
|
||||||
label_borad_project: 项目讨论区
|
label_borad_project: 项目讨论区
|
||||||
label_borad_course: 课程讨论区
|
label_borad_course: 课程讨论区
|
||||||
label_memo_new_from_forum: 发布帖子
|
label_memo_new_from_forum: 发布帖子
|
||||||
|
label_forum: 讨论区
|
||||||
|
label_tags_forum_description: 讨论区描述
|
||||||
|
label_tags_forum: 讨论区名称
|
||||||
|
|
Loading…
Reference in New Issue