diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb
index 71c9b0e7..bcd9992b 100644
--- a/app/controllers/tags_controller.rb
+++ b/app/controllers/tags_controller.rb
@@ -11,6 +11,7 @@ class TagsController < ApplicationController
include BidsHelper
include ForumsHelper
include AttachmentsHelper
+ include ContestsHelper
include ActsAsTaggableOn::TagsHelper
helper :projects
include TagsHelper
@@ -30,7 +31,7 @@ class TagsController < ApplicationController
# 最后是2个过滤何种数据,显示结果的控制参数params[:obj_id],params[:object_falg]
# 0代表删除tag 1代表增加tag
def index
-
+
@obj_id = params[:obj_id]
@obj_flag = params[:object_flag]
@@ -44,28 +45,29 @@ class TagsController < ApplicationController
@tag = params[:tag]
@selected_tags = params[:current_selected_tags]
@selected_tags = @selected_tags.nil? ? Array.new : @selected_tags
-
+
case @do_what
when '0' then
- @selected_tags.delete @tag #数组中删除有多方式 可以改用shift,pop
+ @selected_tags.delete @tag #数组中删除有多方式 可以改用shift,pop
when '1' then
- # 判断是否已存在该tag 主要用来处理分页的情况
- unless @selected_tags.include? @tag
- @selected_tags << @tag
- end
+ # 判断是否已存在该tag 主要用来处理分页的情况
+ unless @selected_tags.include? @tag
+ @selected_tags << @tag
+ end
end
end
-
- @users_tags_num,@projects_tags_num,@issues_tags_num,@bids_tags_num,
+
+ @users_tags_num,@projects_tags_num,@issues_tags_num,@bids_tags_num,@contests_tags_num,
@forum_tags_num, @attachments_tags_num = get_tags_size
-
+
# 获取搜索结果
@obj,@obj_pages,@results_count,@users_results,
@projects_results,
@issues_results,
@bids_results,
@forums_results,
- @attachments_results = refresh_results(@obj_id,@obj_flag,@selected_tags)
+ @attachments_results,
+ @contests_tags = refresh_results(@obj_id,@obj_flag,@selected_tags)
# 这里是做tag推荐用的, 用来生产推荐的tags
unless @obj.nil?
@@ -74,13 +76,13 @@ class TagsController < ApplicationController
# @selected_tags.each do |i|
# @tags.delete(i)
# end
- @related_tags = @tags
+ @related_tags = @tags
else
return
end
end
-
+
# 增加已选的tag
def add_tag
@tag = params[:tag]
@@ -90,11 +92,13 @@ class TagsController < ApplicationController
$related_tags.delete(@tag)
# 获取搜索结果
- @obj,@obj_pages,@users_results,
+ @obj,@obj_pages,@results_count,@users_results,
@projects_results,
@issues_results,
@bids_results,
- @forums_results = refresh_results(@obj_id,@show_flag)
+ @forums_results,
+ @attachments_results,
+ @contests_results = refresh_results(@obj_id,@show_flag)
end
# 删除已选tag
@@ -110,13 +114,15 @@ class TagsController < ApplicationController
@projects_results,
@issues_results,
@bids_results,
- @forums_results = refresh_results(@obj_id,@show_flag)
+ @forums_results,
+ @attachments_results,
+ @contests_results = refresh_results(@obj_id,@show_flag)
end
def show_all
- @tags = ActsAsTaggableOn::Tag.find(:all)
+ @tags = ActsAsTaggableOn::Tag.find(:all)
end
-
+
# 完全从数据库删除tag
# 这种删除方式是针对 印有该 tag所有对象来做删除的
# 这样是从整个系统数据库中把该tag删除了
@@ -149,24 +155,24 @@ class TagsController < ApplicationController
# if can_remove_tag?(User.current,@taggable_id,@taggable_type)
- @taggings = ActsAsTaggableOn::Tagging.find_by_tag_id_and_taggable_id_and_taggable_type(@tag_id,@taggable_id,@taggable_type)
-
- unless @taggings.nil?
- @taggings.delete
- end
+ @taggings = ActsAsTaggableOn::Tagging.find_by_tag_id_and_taggable_id_and_taggable_type(@tag_id,@taggable_id,@taggable_type)
+
+ unless @taggings.nil?
+ @taggings.delete
+ end
# 是否还有其他记录 引用了 tag_id
- @tagging = ActsAsTaggableOn::Tagging.find_by_tag_id(@tag_id)
+ @tagging = ActsAsTaggableOn::Tagging.find_by_tag_id(@tag_id)
# 如果taggings表中记录已经不存在 ,那么检查tags表 作删除动作
- if @tagging.nil?
- @tag = ActsAsTaggableOn::Tag.find_by_id(@tag_id)
- @tag.delete unless @tag.nil?
- end
+ if @tagging.nil?
+ @tag = ActsAsTaggableOn::Tag.find_by_id(@tag_id)
+ @tag.delete unless @tag.nil?
+ end
# end
end
end
-private
+ private
# 这里用来刷新搜索结果的区域
# 函数的返回值 前2字段用来处理获取其他tag和分页 ,另外4个返回值为过滤结果
def refresh_results(obj_id,obj_flag,selected_tags)
@@ -174,11 +180,12 @@ private
@projects_results = nil
@issues_results = nil
@bids_results = nil
+ @contests_results = nil
@forums_results = nil
attachments_results = nil
@obj_pages = nil
@obj = nil
-
+
# 这里为了提高系统的响应速度 把搜索结果放到case中去了
case obj_flag
when '1' then
@@ -199,10 +206,22 @@ private
when '6'
@obj = Attachment.find_by_id(obj_id)
@obj_pages, attachments_results, @results_count = for_pagination(get_attachments_by_tag(selected_tags))
+ when '7'
+ @obj = Contest.find_by_id(obj_id)
+ @obj_pages,@contests_results,@results_count = for_pagination(get_contests_by_tag(selected_tags))
else
- @obj = nil
+ @obj = nil
end
- return @obj,@obj_pages,@results_count,@users_results,@projects_results,@issues_results,@bids_results,@forums_results, attachments_results
+ return [@obj,
+ @obj_pages,
+ @results_count,
+ @users_results,
+ @projects_results,
+ @issues_results,
+ @bids_results,
+ @forums_results,
+ attachments_results,
+ @contests_results]
end
def for_pagination(results)
@@ -222,7 +241,8 @@ private
@bids_tags_num = Bid.tag_counts.size
forum_tags_num = Forum.tag_counts.size
attachment_tags_num = Attachment.tag_counts.size
- return @users_tags_num,@projects_tags_num,@issues_tags_num,@bids_tags_num, forum_tags_num, attachment_tags_num
+ @contests_tags_num = Contest.tag_counts.size
+ return @users_tags_num,@projects_tags_num,@issues_tags_num,@bids_tags_num, forum_tags_num, attachment_tags_num, @contests_tags_num
end
# 通过数字 来转换出对象的类型
@@ -243,6 +263,8 @@ private
return 'Forum'
when '6'
return 'Attachment'
+ when '7'
+ return 'Contest'
else
render_error :message => e.message
return
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index e9e64918..446266fb 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -653,6 +653,8 @@ class UsersController < ApplicationController
@obj = Forum.find_by_id(@obj_id)
when '6'
@obj = Attachment.find_by_id(@obj_id)
+ when '7' then
+ @obj = Contest.find_by_id(@obj_id)
else
@obj = nil
end
diff --git a/app/helpers/tags_helper.rb b/app/helpers/tags_helper.rb
index c4ee5273..ba2470fe 100644
--- a/app/helpers/tags_helper.rb
+++ b/app/helpers/tags_helper.rb
@@ -5,15 +5,17 @@ module TagsHelper
@obj = nil
case obj_type
when '1'
- @obj = User.find_by_id(obj_id)
+ @obj = User.find_by_id(obj_id)
when '2'
@obj = Project.find_by_id(obj_id)
when '3'
@obj = Issue.find_by_id(obj_id)
when '4'
- @obj = Bid.find_by_id(obj_id)
+ @obj = Bid.find_by_id(obj_id)
when '6'
@obj = Attachment.find_by_id(obj_id)
+ when '7'
+ @obj= Contest.find_by_id(obj_id)
else
raise Exception, '[TagsHelper] ===> tag type unknow.'
end
@@ -40,6 +42,10 @@ module TagsHelper
if user.id == obj_id
@result = true
end
+ when '7'
+ if user.id == obj_id
+ @result = true
+ end
end
return @result
end
diff --git a/app/views/contests/_list_softapplications.html.erb b/app/views/contests/_list_softapplications.html.erb
index 2c2034a5..29c985b7 100644
--- a/app/views/contests/_list_softapplications.html.erb
+++ b/app/views/contests/_list_softapplications.html.erb
@@ -1,41 +1,35 @@
<% contesting_softapplication.each do |c_softapplication|%>
<% if c_softapplication.softapplication %>
-
+
+
+
+ 应用软件: |
+
+ <%= link_to(c_softapplication.softapplication.name, softapplication_path(c_softapplication.softapplication)) %>
+ |
+
+
+
+ 简介: |
-
-
-
-
-
-
-
-
- <%= link_to(c_softapplication.softapplication.name, softapplication_path(c_softapplication.softapplication)) %>
-
- <%= l(:label_joined_contest)%>
- |
-
-
-
- <%= c_softapplication.softapplication.description %> |
-
-
-
-
- <%=format_time c_softapplication.created_at %>
- |
-
-
- |
-
-
-
+ <%= c_softapplication.softapplication.description %>
|
-
-
+
+
+
+
+ 发布时间: |
+
+ <%=format_time c_softapplication.created_at %>
+ |
+
+
+
+
<% end %>
+
<% end %>
diff --git a/app/views/contests/_softapplication_list.html.erb b/app/views/contests/_softapplication_list.html.erb
index ee4b3792..e5d03012 100644
--- a/app/views/contests/_softapplication_list.html.erb
+++ b/app/views/contests/_softapplication_list.html.erb
@@ -7,7 +7,7 @@
- <%= link_to(l(:button_contesting_as_application), {:controller => 'softapplications', :action => 'new'}) %>
+ <%= link_to l(:button_contesting_as_application), "javascript:void(0);", onclick: "$('#put-bid-form').toggle();" %>
|
<% end %>
diff --git a/app/views/contests/show_softapplication.html.erb b/app/views/contests/show_softapplication.html.erb
index 068ac79c..6c932df5 100644
--- a/app/views/contests/show_softapplication.html.erb
+++ b/app/views/contests/show_softapplication.html.erb
@@ -59,7 +59,7 @@
<% if User.current.logged? %>
-