From 538f8516b0e4c556081969f3cce8ab608d1ebc87 Mon Sep 17 00:00:00 2001 From: wanglinchun Date: Thu, 8 May 2014 16:49:52 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9B=AE=E5=89=8D=E5=B7=B2=E7=BB=8F=E9=80=9A?= =?UTF-8?q?=E8=BF=87=E5=88=A4=E6=96=AD=E5=B0=86=E5=B1=9E=E4=BA=8E=E7=AB=9E?= =?UTF-8?q?=E8=B5=9B=E7=9A=84=E9=A1=B9=E7=9B=AE=E6=88=96=E6=98=AF=E5=BA=94?= =?UTF-8?q?=E7=94=A8=E6=98=BE=E7=A4=BA=E5=88=B0=E6=88=91=E8=A6=81=E5=8F=82?= =?UTF-8?q?=E8=B5=9B=E7=9A=84=E4=BD=9C=E5=93=81=E5=88=97=E8=A1=A8=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/contests_controller.rb | 46 +++++++- .../contests/show_attendingcontest.html.erb | 100 ++++++++++++------ 2 files changed, 113 insertions(+), 33 deletions(-) diff --git a/app/controllers/contests_controller.rb b/app/controllers/contests_controller.rb index bb5b85a1..7e27d117 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 993c63f2..90f32aff 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 %> +