From 0af95aa86f10c2566f8f86b154b21e5f789feb88 Mon Sep 17 00:00:00 2001 From: p31729568 Date: Mon, 15 Jul 2019 18:29:52 +0800 Subject: [PATCH 1/3] competition list add filter --- app/controllers/competitions_controller.rb | 2 ++ app/views/competitions/index.html.erb | 2 ++ 2 files changed, 4 insertions(+) diff --git a/app/controllers/competitions_controller.rb b/app/controllers/competitions_controller.rb index e73c779a..1a42a9c6 100644 --- a/app/controllers/competitions_controller.rb +++ b/app/controllers/competitions_controller.rb @@ -28,6 +28,8 @@ class CompetitionsController < ApplicationController competitions = Competition.where('status = 1 or published_at is not null') case params[:category] + when 'nearly_published' then + competitions = competitions.where('published_at is not null AND status = 0') when 'progressing' then competitions = competitions.where('end_time > NOW()') when 'ended' then diff --git a/app/views/competitions/index.html.erb b/app/views/competitions/index.html.erb index 36743613..44607ef8 100644 --- a/app/views/competitions/index.html.erb +++ b/app/views/competitions/index.html.erb @@ -3,6 +3,8 @@
<%= link_to '全部', competitions_path(category: ''), remote: true, class: "fl mr20 font-16 bestChoose shixun_repertoire #{params[:category].blank? ? 'active' : ''}" %> + <%= link_to '即将发布', competitions_path(category: 'nearly_published'), remote: true, + class: "fl mr20 font-16 bestChoose shixun_repertoire #{params[:category] == 'nearly_published' ? 'active' : ''}" %> <%= link_to '进行中', competitions_path(category: 'progressing'), remote: true, class: "fl mr20 font-16 bestChoose shixun_repertoire #{params[:category] == 'progressing' ? 'active' : ''}" %> <%= link_to '往期比赛', competitions_path(category: 'ended'), remote: true, From 796f41f6a905541bb4a29b9d30c1512a644c12a2 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Tue, 16 Jul 2019 10:41:34 +0800 Subject: [PATCH 2/3] 1 --- app/services/games_service.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/services/games_service.rb b/app/services/games_service.rb index b40edbf4..1d69906a 100644 --- a/app/services/games_service.rb +++ b/app/services/games_service.rb @@ -846,7 +846,7 @@ class GamesService experience = 0 game_status = game.status had_done = game.had_done - game_challenge = Challenge.select([:id, :score, :position, :shixun_id, :web_route, :picture_path]).find(game.challenge_id) + game_challenge = Challenge.select([:id, :score, :position, :shixun_id, :web_route, :show_type]).find(game.challenge_id) shixun = Shixun.select([:id, :status, :user_id, :test_set_permission]).find(game_challenge.shixun_id) if params[:resubmit].blank? # 非重新评测 From 0793702299cd6ab197d742fb62210a78f0559e54 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Tue, 16 Jul 2019 11:07:47 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E7=AB=9E=E8=B5=9B=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E9=A1=B5=E7=9A=84=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/managements_controller.rb | 2 +- app/models/competition_team.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/managements_controller.rb b/app/controllers/managements_controller.rb index dc8f6dea..3a66aff4 100644 --- a/app/controllers/managements_controller.rb +++ b/app/controllers/managements_controller.rb @@ -1087,7 +1087,7 @@ end @only_teacher = @competition.competition_staffs.count == 1 && @competition.competition_staffs.first.category == 'teacher' @team_members = @competition.team_members - @team_members = @team_members.where(is_teacher: false) unless @only_teacher # 只有老师报名时才显示老师,此时老师作为队员 + @team_members = @team_members.where("team_members.is_teacher = 0") unless @only_teacher # 只有老师报名时才显示老师,此时老师作为队员 if params[:school] || params[:location] school_ids = School.where("schools.name like '%#{params[:school]}%'").pluck(:id) diff --git a/app/models/competition_team.rb b/app/models/competition_team.rb index 84dcac81..e2551710 100644 --- a/app/models/competition_team.rb +++ b/app/models/competition_team.rb @@ -4,8 +4,8 @@ class CompetitionTeam < ActiveRecord::Base belongs_to :competition has_many :team_members, :dependent => :destroy - has_many :members, conditions: 'is_teacher = 0', class_name: 'TeamMember' - has_many :teachers, conditions: 'is_teacher = 1', class_name: 'TeamMember' + has_many :members, conditions: 'team_members.is_teacher = 0', class_name: 'TeamMember' + has_many :teachers, conditions: 'team_members.is_teacher = 1', class_name: 'TeamMember' has_many :competition_scores, :dependent => :destroy # team_type 0:组队 1:个人 # attr_accessible :invite_code, :name, :team_type