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/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) diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 2f07b182..83ec54f8 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -1115,8 +1115,8 @@ 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 # 关联删报错,后续解决 - @shixun.destroy + #HomeworkCommonsShixuns.where(:shixun_id => @shixun).delete_all # 关联删报错,后续解决 + @shixun.update_attribute(:status, -1) respond_to do |format| if params[:come_from] == "admin" format.html{ redirect_to shixuns_managements_path } @@ -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 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