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 @@ } - +