From f8611f90b628bfaf19d2beb224e9f19cd666c877 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Mon, 1 Apr 2019 09:22:07 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E8=BF=81=E7=A7=BB=E6=8A=A5=E9=94=99?= =?UTF-8?q?=E7=9A=84=E5=AE=9E=E8=AE=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/shixuns_controller.rb | 2 +- app/models/shixun.rb | 2 +- .../20190401011345_modify_fork_from_for_shixuns.rb | 11 +++++++++++ 3 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 db/migrate/20190401011345_modify_fork_from_for_shixuns.rb diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 2f07b182..d91ec474 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -1116,7 +1116,7 @@ class ShixunsController < ApplicationController apply_record = ApplyAction.where(:container_id => @shixun.id, :container_type => "ApplyShixun") apply_record.delete_all if apply_record HomeworkCommonsShixuns.where(:shixun_id => @shixun).delete_all # 关联删报错,后续解决 - @shixun.destroy + @shixun.update_attribute(:status, -1) respond_to do |format| if params[:come_from] == "admin" format.html{ redirect_to shixuns_managements_path } diff --git a/app/models/shixun.rb b/app/models/shixun.rb index 0a7fff62..6ab98172 100644 --- a/app/models/shixun.rb +++ b/app/models/shixun.rb @@ -73,7 +73,7 @@ class Shixun < ActiveRecord::Base end def fork_identifier - self.fork_from.nil? ? "--" : Shixun.find(self.fork_from).try(:identifier) + self.fork_from.nil? ? "--" : Shixun.where(id: self.fork_from).first.try(:identifier) end def get_fork diff --git a/db/migrate/20190401011345_modify_fork_from_for_shixuns.rb b/db/migrate/20190401011345_modify_fork_from_for_shixuns.rb new file mode 100644 index 00000000..98dc7c1e --- /dev/null +++ b/db/migrate/20190401011345_modify_fork_from_for_shixuns.rb @@ -0,0 +1,11 @@ +class ModifyForkFromForShixuns < ActiveRecord::Migration + def up + shixuns = Shixun.where(:fork_from => 1933) + shixuns.each do |shixun| + shixun.update_attribute(:fork_from, nil) + end + end + + def down + end +end From ed87d56f6cc00542340097876bf3bdfc4f8b7109 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Mon, 1 Apr 2019 10:13:24 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=AE=9E=E8=AE=AD?= =?UTF-8?q?=E7=9A=84=E8=AE=BF=E9=97=AE=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/challenges_controller.rb | 2 +- app/controllers/shixuns_controller.rb | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/controllers/challenges_controller.rb b/app/controllers/challenges_controller.rb index 54f545e5..5bd8f537 100644 --- a/app/controllers/challenges_controller.rb +++ b/app/controllers/challenges_controller.rb @@ -465,7 +465,7 @@ class ChallengesController < ApplicationController render_404 return else - if (@shixun.status == 0 && !User.current.manager_of_shixun?(@shixun)) + if (@shixun.status == 0 && !User.current.manager_of_shixun?(@shixun)) || @shixun.status == -1 render_403 return end diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index d91ec474..95d19d93 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -1215,7 +1215,7 @@ class ShixunsController < ApplicationController # Find shixun of id params[:id] def find_shixun @shixun = Shixun.find_by_identifier(params[:id]) - render_404 if @shixun.nil? + render_404 if @shixun.nil? || @shixun.status == -1 rescue ActiveRecord::RecordNotFound render_404 end @@ -1362,4 +1362,8 @@ class ShixunsController < ApplicationController def validation_email render_403 if User.current.mail.blank? end + + def validate_shixun + + end end From 8950bafb188f45c87dc2eb488cf358f38c7e56f0 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Mon, 1 Apr 2019 10:17:18 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=AE=9E=E8=AE=AD=20'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/shixuns_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 95d19d93..83ec54f8 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -1115,7 +1115,7 @@ class ShixunsController < ApplicationController g.delete_project(@shixun.gpid) if @shixun.try(:gpid).present? apply_record = ApplyAction.where(:container_id => @shixun.id, :container_type => "ApplyShixun") apply_record.delete_all if apply_record - HomeworkCommonsShixuns.where(:shixun_id => @shixun).delete_all # 关联删报错,后续解决 + #HomeworkCommonsShixuns.where(:shixun_id => @shixun).delete_all # 关联删报错,后续解决 @shixun.update_attribute(:status, -1) respond_to do |format| if params[:come_from] == "admin" From 38eb71d7f2eeee95e5343b5e5952087ded2cd1e7 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Mon, 1 Apr 2019 12:02:49 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E5=AE=9E=E8=AE=ADtpi=E7=9A=84=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E5=BA=93=E5=8F=AF=E4=BB=A5=E9=80=9A=E8=BF=87id?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/managements_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/managements_controller.rb b/app/controllers/managements_controller.rb index d5e8c682..0d17ccf6 100644 --- a/app/controllers/managements_controller.rb +++ b/app/controllers/managements_controller.rb @@ -158,7 +158,7 @@ class ManagementsController < ApplicationController @sub_type = 8 @g = Gitlab.client if params[:search] - myshixun_id = Game.where(:identifier => params[:search]).pluck(:myshixun_id) + myshixun_id = Game.where("identifier = #{params[:search]} or id = #{params[:search]}").pluck(:myshixun_id) @myshixuns = Myshixun.where(:id => myshixun_id).includes(:shixun) else @myshixuns = Myshixun.where("0=0").includes(:shixun)