From 0c478172eeb769560bf92c6c2b351c784723c42b Mon Sep 17 00:00:00 2001 From: p31729568 Date: Sat, 29 Jun 2019 14:06:02 +0800 Subject: [PATCH 1/2] new competition --- .../_gq_second_code_competition.html.erb | 6 ++-- .../_qg_second_course_competition.html.erb | 34 ++++++++++++++----- app/views/competitions/show.html.erb | 2 ++ 3 files changed, 30 insertions(+), 12 deletions(-) diff --git a/app/views/competitions/_gq_second_code_competition.html.erb b/app/views/competitions/_gq_second_code_competition.html.erb index ccdfe190..35c5dd17 100644 --- a/app/views/competitions/_gq_second_code_competition.html.erb +++ b/app/views/competitions/_gq_second_code_competition.html.erb @@ -34,11 +34,11 @@ ] %> -<% @competition.competition_stages.each_with_index do |stage, i| %> +<% @competition.competition_stages.includes(:competition_stage_sections).each_with_index do |stage, i| %>
<% - first_section = stage.competition_stage_sections.first - second_section = stage.competition_stage_sections.second + first_section = stage.competition_stage_sections[0] + second_section = stage.competition_stage_sections[1] %>
"> <% if i.zero? %> diff --git a/app/views/competitions/_qg_second_course_competition.html.erb b/app/views/competitions/_qg_second_course_competition.html.erb index 92d2a9f9..b808deab 100644 --- a/app/views/competitions/_qg_second_course_competition.html.erb +++ b/app/views/competitions/_qg_second_course_competition.html.erb @@ -1,14 +1,30 @@ -

-

-

-

-
+<% index = 0 %> +

+<% index += 1 %> +

+<% index += 1 %> +

+<% index += 1 %> +

+<% index += 1 %> + +<% + stage = @competition.competition_stages.first + first_section = stage.competition_stage_sections.first + is_start = Time.now > first_section.start_time +%> + -

+<% index += 1 %> + +

diff --git a/app/views/competitions/show.html.erb b/app/views/competitions/show.html.erb index 1549c46d..0df98a24 100644 --- a/app/views/competitions/show.html.erb +++ b/app/views/competitions/show.html.erb @@ -11,5 +11,7 @@ <%= render :partial => "qg_second_competition" %> <% elsif @competition.identifier == "gcc-annotation-2019" %> <%= render :partial => "gq_second_code_competition" %> + <% elsif @competition.identifier == "gcc-course-2019" %> + <%= render :partial => "qg_second_course_competition" %> <% end %>
\ No newline at end of file From 65523c2d2c2a0b776f1a1468b42a5e252664c837 Mon Sep 17 00:00:00 2001 From: p31729568 Date: Sat, 29 Jun 2019 14:10:43 +0800 Subject: [PATCH 2/2] fix competition join team --- app/controllers/competition_teams_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/competition_teams_controller.rb b/app/controllers/competition_teams_controller.rb index 0d78fb58..817de9be 100644 --- a/app/controllers/competition_teams_controller.rb +++ b/app/controllers/competition_teams_controller.rb @@ -145,7 +145,7 @@ class CompetitionTeamsController < ApplicationController # 老师身份加入战队 if User.current.user_extensions.identity == 0 - teacher_staff = @competition.where(category: 'teacher').first + teacher_staff = @competition.competition_staffs.where(category: 'teacher').first if teacher_staff.blank? @status, @message = -1, '该竞赛不能配备导师' @@ -158,7 +158,7 @@ class CompetitionTeamsController < ApplicationController end team.team_members.create!(user_id: User.current.id, role: 3, competition_id: @competition.id, is_teacher: true) else - max_member_count = @competition.where('category != "teacher"').sum(:maximum) + max_member_count = @competition.competition_staffs.where('category != "teacher"').sum(:maximum) if team.members.count + 1 > max_member_count @status, @message = -1, '该战队成员人数已满' return