diff --git a/app/controllers/contests_controller.rb b/app/controllers/contests_controller.rb index bb5b85a1a..7e27d1171 100644 --- a/app/controllers/contests_controller.rb +++ b/app/controllers/contests_controller.rb @@ -253,6 +253,7 @@ class ContestsController < ApplicationController ############ ##显示参赛的应用 def show_softapplication + # @membership = User.current.memberships.all(:conditions => Project.visible_condition(User.current)) # @option = [] @@ -292,10 +293,53 @@ class ContestsController < ApplicationController ###我要参赛 def show_attendingcontest +##取出参赛项目 + @membership = User.current.memberships.all(:conditions => Project.visible_condition(User.current)) + @option = [] + # @contesting_project_count = @contesting_project_all.count + # @contesting_project_pages = Paginator.new @contesting_project_count, per_page_option, params['page'] + @membership.each do |membership| + unless(membership.project.project_type==1) + membership.member_roles.each{|role| + if(role.role_id == 3) + @option << membership.project + end + } + end + end + @user = @contest.author + @contesting_project = @contest.contesting_projects.all + if params[:student_id].present? + @temp = [] + @contesting_project.each do |pro| + if pro.project && pro.project.project_status + if /#{params[:student_id]}/ =~ pro.user.user_extensions.student_id + @temp << pro + end + end + @temp + end + @contesting_project = @temp + else + + @temp = [] + @contesting_project.each do |pro| + if pro.project && pro.project.project_status + @temp << pro + end + @temp + end + if @temp.size > 0 + @contesting_project = @temp.sort {|a,b| b.project.project_status.grade <=> a.project.project_status.grade} + end + end +##取出参赛应用 @softapplication = Softapplication.all @contesting_softapplication = @contest.contesting_softapplications @contesting_softapplication = paginateHelper @contesting_softapplication, 10 - ##引用base_newcontest整体样式 + + +##引用base_newcontest整体样式 @contest = Contest.find_by_id(params[:id]) respond_to do |format| format.html { diff --git a/app/views/contests/show_attendingcontest.html.erb b/app/views/contests/show_attendingcontest.html.erb index 993c63f28..90f32affc 100644 --- a/app/views/contests/show_attendingcontest.html.erb +++ b/app/views/contests/show_attendingcontest.html.erb @@ -55,11 +55,11 @@ } - +
温馨提示:如果您希望在我们平台托管参赛数据和代码,请按下面参赛步骤参赛!
<% if User.current.logged? %> -
+
参赛步骤:
步骤1: @@ -100,41 +100,77 @@ <% end %> - + +<% if @contest.id == 2 or @contest.id == 3 or @contest.id == 6 %> -<% @contesting_softapplication.each do |c_softapplication|%> - <% if c_softapplication.softapplication %> -
-
- - 应用软件: - - <%= link_to(c_softapplication.softapplication.name, softapplication_path(c_softapplication.softapplication), :target => '_blank') %> - -
+ <% @contesting_project.each do |c_project|%> + <% if c_project.project %> +
+
+ + 参赛作品: + + <%= link_to(c_project.project.name, project_path(c_project.project), :target => '_blank') %> + +
+
+
+ + 简介: + + <%= c_project.project.description.truncate(90, omission: '...') %> + +
+
+
+ + 发布时间: + + <%= format_time c_project.created_at%> + + + +
-
- - 简介: - - <%= c_softapplication.softapplication.description.truncate(90, omission: '...') %> - -
-
-
- - 发布时间: - - <%=format_time c_softapplication.created_at %> - - - -
-
+ <% end %> +
+ <% end %> +<% else %> + <% @contesting_softapplication.each do |c_softapplication|%> + <% if c_softapplication.softapplication %> +
+
+ + 参赛作品: + + <%= link_to(c_softapplication.softapplication.name, softapplication_path(c_softapplication.softapplication), :target => '_blank') %> + +
+
+
+ + 简介: + + <%= c_softapplication.softapplication.description.truncate(90, omission: '...') %> + +
+
+
+ + 发布时间: + + <%=format_time c_softapplication.created_at %> + + + +
+
+ <% end %> +
<% end %> -
<% end %> +